I saw Javascript code that claims to speed up function calls, for example:
function foo() { // do something } function myFunc() { var fastFoo = foo; // this caches function foo locally for faster lookups for (var i = 0; i < 1000; i++) { fastFoo(); } }
I donβt see how this can speed up work on calling the javascript function, since it seems to me that this is just a search in memory, either at the top of the current stack (for fastFoo), or somewhere else on the stack (I am not sure where global context stored ... anyone?).
Is this a relic of ancient browsers, a complete myth or a true improvement improver?
source share