3 ms·
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 ob
by jholman 9y ago
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.)
- sethrin 9y agoI 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.