function a(x){
alert(x)
}
function b(){
arguments[0] =1;
alert(arguments[0])
a.apply( this, arguments );
}
b()第一次弹出1貌似已经修改了
为什么a还是取不到呢
alert(x)
}
function b(){
arguments[0] =1;
alert(arguments[0])
a.apply( this, arguments );
}
b()第一次弹出1貌似已经修改了
为什么a还是取不到呢
解决方案 »
- jquery的contents函数获取iframe的问题
- 如何匹配任意字符串 包括问号
- JS Bingo游戏无法实现的随机数
- JS的速度特别慢,求解,谢谢!
- 浏览器的上网助手可以拦截弹出广告,请问我的弹出窗口程序怎么写?
- 两个文本框数值做乘除,为什么有时会出现计算结果位数过多现象?立即给分!
- 也许你感觉很简单,但是我不会,帮帮我!
- 怎样处理TextArea,使之自动自适应文字行数的多少?
- 急!~~~~~~急!请各位大虾帮忙,一定给分.
- 请问怎么样用jsript得到document的实际高度呢?
- 【---THIS--------THIS--------】
- 选择文件路径窗口的问题。熟悉JQuery或JavaScript的朋友请进来。
alert(x[0])
}
function b(){
arguments[0] =1;
alert(Object.prototype.toString.call(arguments) === "[object Array]")
alert(arguments[0])
a.apply( this, [arguments] );
}
b() apply第2个参数是数组 arguments不是数组//---------------------------
alert(x);
alert("len:" + x.length);
alert('x[0]:'+ x[0]);
}
function b(){
arguments[0] =1;//相当于是一个object的属性
alert(arguments[0]);//1
a(arguments);//object
alert(typeof arguments);//object
a.apply(this, [arguments]);//这里的arguments是一个array传递的
}
b();
个人理解,仅供参考
alert(x)
}
function b(){
arguments[0] =1;
alert(arguments.length)
arguments.length=1
a.apply( this, arguments );
}
b()这样就可以
原来要手动修改length
ECMA 10.1.8 Arguments Object 最后有这么一段话
In the case when arg is less than the number of formal parameters for the Function object, this property shares its value with the corresponding property of the activation object. This means that changing this property changes the corresponding property of the activation object and vice versa.
深层可以理解为.只有虚参有相应实参对应时候.才具有共享作用.所以你的代码如果加个参数就可以了.
function a(x){
alert(x)
}
function b(){
arguments[0] = 1;
alert(arguments[0])
a.apply( this, arguments );
}
b(0)
再给你一个例子
function foo(a, b, c) {
arguments[0] = 2;
alert(a);
c = 3;
/*由于c没有对应的实参所以,此处不应共享应为undefined.但Chrome这个处理是个BUG.其余浏览器正常*/
alert(arguments[2]);
}
foo(1, 2);
我的问题跟你的这个不太一样
我的是类数组的问题
你加了参数后arguments.length就自动变成1了不过你说的共享问题我也不知道 学习了