Adam Brodziak
1 min readJun 5, 2020


Why bother with all the caveats of constructor in JavaScript if you can write a factory function that will return an object instead? It has got the same effect, but skips new insanity. This is how simple it is:

const createPerson = ({ name }) => ({
setName(name) { = name;
return this;

const joe = createPerson({ name: 'Joe Doe' });

The trick with instanceof is clever, but due you really need such tricks all over the place?

I’ve presented factory pattern and other useful ones in my post



Recommended from Medium


See more recommendations