Interesting. So I guess you encourage to export … what? ES5 constructors instead?
Aliaksandr Astashenkau
1

Factory functions. In JavaScript, any function can instantiate and return an object. When that function is not a constructor (which is what ES6 `class` desugars to), it’s called a factory. Factories are not extendable the same way ES5 constructors and ES6 classes are, which is what makes them safer to use. They also don’t require the `new` keyword, which can tie you to the constructor implementation for object instantiation, which takes options off the table if you later need to use factories for their added flexibility.

See “The Two Pillars of JavaScript: How to Escape the 7th Circle of Hell”.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.