What is the primary purpose of a factory function in JavaScript?
Factory functions in JavaScript serve to create and return objects: 1) They encapsulate object creation logic in a reusable function, 2) They provide a clean interface for creating complex objects, 3) They allow creating multiple objects with similar structure without using classes or constructors, 4) They enable closure-based private state, 5) They make object creation more explicit and declarative, 6) They avoid issues with 'this' binding that constructor functions can have.