3 ms·
> You can see every single rebinding of a variable within the lexical scope of the function, I do not think that is true, a called function can side effect the
by riffraff 11y ago
> You can see every single rebinding of a variable within the lexical scope of the function,
I do not think that is true, a called function can side effect the caller environment via `arguments` if that is passed around.
- braythwayt 11y agoMy understanding is that arguments caller has been removed, and Function.prototype.caller is non-standard: > The obsolete `arguments.caller` property used to provide the > function that invoked the currently executing function. This > property has been removed and no longer works. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Can you provide an example of modifying a declared variable in a calling environment? I'm very interested!
- riffraff 11y agoI meant this: function sidEffecting(ary) { ary[0] = ary[2]; } function bar(a,b,c) { c = 10 sidEffecting(arguments); return a + b + c; } bar(1,1,1) // I expect 12, but is 21 I now realize this could actually be not allowed anymore in recent ES, I am not sure, but copy & paste in chrome console still prints 21.