Create Factory Functions for Object Composition

Share this video with your friends

Send Tweet

Factory functions can be powerful ways of abstracting away difficult inheritance situations. They are simply functions that return objects in a desired state. Let’s refactor some objects that share duplicated code to a reusable factory function.

alwin
alwin
~ 6 years ago

"Factory functions are any function that's not called with a new keyword and returns a new object." Classic.