3 ms·
It helped me immensely when I realized obj.method(); is a sugar for obj.method.call(obj); Similarly, this picture helped me understand `bind`: http
by danabramov 12y ago
It helped me immensely when I realized
obj.method();
is a sugar for
obj.method.call(obj);
Similarly, this picture helped me understand `bind`:
http://i.stack.imgur.com/StZOr.png http://i.stack.imgur.com/StZOr.png
The a-ha moment for JS is when you realize it's a way simpler language than you thought it was.
- jameshart 12y agoYes - the trick with JS is to realize it has this functional core, and every object has an __proto__ property, and then most of its syntax is syntactic sugar over the top of that. new method() is syntactic sugar for something like var _tmp = {}; _tmp.__proto__ = method.prototype; _tmp.call(method);