this 是一个隐藏参数

    arugments 是一个普通参数

    我们要最先知道 this 的指向在函数定义的时候确定不了,只有在函数执行的时候才能确定。也就是说this最终指向调用它的对象。

    1. function fn(){
    2. console.log(arguments);
    3. console.log(this);
    4. }
    5. fn.call(1,2,3)
    6. // 输出
    7. // Arguments(2) [2, 3, callee: ƒ, Symbol(Symbol.iterator): ƒ]
    8. // Number {1}

    这里this就是 call()里面的一个数,它是一个数字1。

    1. function fn(){
    2. console.log(arguments);
    3. console.log(this);
    4. }
    5. fn.call(undefined,1,2,3)
    6. // 输出
    7. // Arguments(3) [1, 2, 3, callee: ƒ, Symbol(Symbol.iterator): ƒ]
    8. // Window {window: Window, self: Window, document: document, name: "", location: Location, …}

    这里的this 没有被定义 他就会默认指向上一层对象 也就是window对象。