美文网首页
[js]子调用栈复写不了父调用栈的参数(有意思)

[js]子调用栈复写不了父调用栈的参数(有意思)

作者: 清水芦苇 | 来源:发表于2017-04-25 17:48 被阅读15次

js虽然是一门动态语言,但是本调用栈的arguments对象是不允许在子调用栈复写的。

function func_1() {
    console.log(arguments.callee.caller.arguments); //123
    arguments.callee.caller.arguments[0] = 100;
    console.log(arguments.callee.caller.arguments); //123
}
function func_2() {
    func_1.apply(this, arguments);
}
func_2(123);

相关文章

网友评论

      本文标题:[js]子调用栈复写不了父调用栈的参数(有意思)

      本文链接:https://www.haomeiwen.com/subject/zkavzttx.html