JavaScript: Reference a functions local scope as an object -
when call function, local scope erected call. there way directly reference scope object? window reference global scope object.
example:
function test(foo){ var bar=1 //now, can access object containing foo, bar, arguments , //else within local scope this: magicidentifier.bar }
alternately, have complete list of in local scope on top of custom variables?
background: i'm trying down way of shifting global scope within function call, statement joke, call works little better, still breaks declared in function scope not in global scope, therefore declare these few cases in global scope, requires me know are. ie function execscript makes complete shift, solves problem ie.
note: loading javascript dynamically, settimeout(code,1)
simple effective hack achieve global scope, not execute immediately.
no, there's no way reference variable object of execution context of function binding object of variable environment of execution context (that's thing called [now; hence strikethrough]; details in §10.3 of specification). can access limited view arguments
(which limited indeed).
usually when i've wanted this, i've put wanted on object , used (e.g., passed function). of course, functions created within context have access in scope they're created, "close over" context; more: closures not complicated.
Comments
Post a Comment