JavaScript Design Patterns: Factory