4 ms·
There are much nicer patterns available to program in an Object Oriented (or rather JavaScript) style. In the following gist I demonstrate (using a simple conta
by kalekold 9y ago
There are much nicer patterns available to program in an Object Oriented (or rather JavaScript) style. In the following gist I demonstrate (using a simple container library) private, protected and public members (including methods and properties) along with setting each object up for correct prototypal inheritance.
https://gist.github.com/nomad-software/78be4f1dd429325c5ebede48237f5120 https://gist.github.com/nomad-software/78be4f1dd429325c5ebed...
I would always start with this pattern for readability and maintainability sake and if performance becomes an issue switch to the `Obj.prototype.method = f()` form to avoid duplicating method instances.
- tiuPapa 9y agoWhy symbol.iterator?
- spmurrayzzz 9y agoThis lets you specify the default iterator for an object. Lets you use `for of` on the object just like you can with arrays, maps, strings, sets, and typedarrays.