News for hackers. Stuff that matters.
Re:‘This’ in JavaScript by int_19h on Thursday August 03, 2017 @06:51AM (#14918471)
> Factory functions should be the default everywhere.

Factory functions still need to create the object somehow to return it.

Re:‘This’ in JavaScript by jholman on Thursday August 03, 2017 @07:47AM (#14918704)
Absolutely. The guts of the factory function should usually involve an object literal. Or in some cases, Object.create.

(If we're talking about Java, then obviously you have to have `new` somewhere, which is just one of the many shortcomings of Java, although obviously not a fatal one.)

Re:‘This’ in JavaScript by sethrin on Thursday August 03, 2017 @10:02AM (#14919623)
I do really like JavaScript's ability to compose objects like that, and I feel that people interested in it as a language should definitely learn how to program in that manner. However, I suspect that for most people JavaScript is a means to an end, and it's more useful in a number of senses to try to write JavaScript more like other class-based languages. I mean, I feel like things like TypeScript sort of miss the point of having a dynamically typed language, but there is a solid case to be made for features like strong typing, especially as size and contributors go up.