Can someone clarify the difference between a constructor function and a factory function in Javascript.
When to use one instead of the other?
A constructor returns an instance of the class you call it on. A factory function can return anything. You would use a factory function when you need to return arbitrary values or when a class has a large setup process.