Re:How JavaScript closures work under the hood
by songgao on Sunday September 06, 2015 @12:33PM
(#10178099)
In case you are interested, `Function.prototype.bind` in V8 is implemented here:
https://github.com/nodejs/node/blob/9fddd83cf9adf505bce2e237...
https://github.com/nodejs/node/blob/9fddd83cf9adf505bce2e237...
Re:How JavaScript closures work under the hood
by Lio on Tuesday September 08, 2015 @09:37AM
(#10185554)
That's vert interesting. Thank you.
Re:How JavaScript closures work under the hood
by inglor on Sunday September 06, 2015 @12:30PM
(#10178094)
Here is an answer I wrote about it a while back http://stackoverflow.com/questions/17638305/why-is-bind-slow...
Let me know if you have any questions about it
Re:How JavaScript closures work under the hood
by Lio on Tuesday September 08, 2015 @09:39AM
(#10185567)
That's a great answer, thank you.
Re:How JavaScript closures work under the hood
by draw_down on Sunday September 06, 2015 @12:24PM
(#10178069)
How could test1 here ever be faster than test2? The functions are identical but calling test1 will always incur twice the actual function invocations, first to the bound function and then to _test1.
(http://jsperf.com/bind-vs-closure-setup/44)
Could anyone who knows more about the implementation details point to an explanation of what's going on under the surface?