4 ms·
In my limited experience working with JavaScript, I've found the lack of the following to cause more problems when writing modular, reusable code than the lack
by jfe 11y ago
In my limited experience working with JavaScript, I've found the lack of the following to cause more problems when writing modular, reusable code than the lack of type annotations:
* a single, definitive method for creating namespaces without using a framework or library
* a single, definitive method for defining classes and using inheritance without using a framework or library
* a single, definitive method of allowing async functions to modify the state of an object without having to declare that object in the global scope, without using a framework or library
If these problems are already solved, please let me know!
- Mchl 11y agoThe one about classes is solved by not using classes. Prototypal inheritance works well (and besides, most implementations of 'class-like' behaviour are using prototypes underneath anyway) I'm playing a bit of a devil's advocate here ;)
- tlrobinson 11y agoES6 provides solutions for #1 and #2. These will replace the fragmented existing solutions. I'm not sure I understand #3. Closures? 1. https://babeljs.io/docs/learn-es2015/#modules https://babeljs.io/docs/learn-es2015/#modules 2. https://babeljs.io/docs/learn-es2015/#classes https://babeljs.io/docs/learn-es2015/#classes