是否有可能在javascript中为某个本地var分配别名/引用?
我的意思是C-like:
function foo() {
var x = 1;
var y = &x;
y++;
alert(x); // prints 2
}
Run Code Online (Sandbox Code Playgroud)
=编辑=
是否可以在此代码中为arguments.callee设置别名?:
function foo() {
arguments.callee.myStaticVar = arguments.callee.myStaticVar || 0;
arguments.callee.myStaticVar++;
return arguments.callee.myStaticVar;
}
Run Code Online (Sandbox Code Playgroud) javascript ×1