10 biggest JS pitfalls
domenic at domenicdenicola.com
Sun Dec 30 13:33:40 PST 2012
> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Axel Rauschmayer
> Sent: Sunday, December 30, 2012 16:22
> 9c) using methods as callback functions
The single biggest feature on my ES7 wishlist is the bind operator strawman:
Far ahead of Object.observe or value objects, this alone would make my day-to-day code much simpler.
As-is I stick with the closure pattern for my classes because (a) I get actual encapsulation; and (b) my methods are "bound" without awkward obj.method.bind(obj)—or worse, in ES3 environments: _.bind(obj.method, obj). Compilers hate me for it, and punish me with worse-performing and memory-duplicating code (vs. the prototype pattern), but for now it's been a tradeoff I'm willing to make. Symbols in ES6 fix (a), but we need the bind operator to fix (b).
More information about the es-discuss