kujian/daily-interview-question

第7题:Arguments参数的理解

kujian opened this issue · 0 comments

function test(num1,num2){
    console.log(num1,arguments[0]);
    arguments[0] = 2;
    console.log(num1,arguments[0]);
    num1 = 10;
    console.log(num1,arguments[0]);
}
test(1);

严格模式

function test(num1,num2){
    'use strict';
    console.log(num1,arguments[0]);
    arguments[0] = 2;
    console.log(num1,arguments[0]);
    num1 = 10;
    console.log(num1,arguments[0]);
}
test(1);

无值情况下

function test(num1,num2){
    console.log(num1,arguments[0]);
    num1 = 10;
    arguments[0] = 5;
    console.log(num1,arguments[0]);
}
test();

答案参考:https://www.cnblogs.com/xiaohuochai/p/5706289.html