4 ms·
I think the idea is that the constructor is for dependencies not parameters, things that are REQUIRED to be set at construction time for the sanity of the objec
by vanjajaja1 4y ago
I think the idea is that the constructor is for dependencies not parameters, things that are REQUIRED to be set at construction time for the sanity of the object. Anything that is optional can be set in the normal way after construction eg using Object.assign
If you have a situation where an object with many parameters must be configured with a certain (yet different) subset of parameters in certain scenarios, then you probably want a factory.