Danny Fenstermaker
Jul 25, 2017 · 1 min read

Out of curiosity what would you have against using ES6 classes in conjunction with the factory pattern as a static function?

For example:

class User {    static factory () {        return new User()
}
}

This achieves the benefits of using the factory pattern, allows the use of typeof and isolates the creation of an object via the new operator to a single place.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade