js arguments

偶然碰见一个有意思的题

    
<script>
    var length = 10;
    function fn() {
        console.log( this.length ); // 10
    }
    var obj = {
        length: 5,
        method: function ( fn ) {
            fn();   // 10 前面没有引导对象,是函数调用模式
            arguments[0](); // 2
            console.log(arguments[0]);
            console.log(arguments[1]);
            console.log(arguments[2]);
            // arguments是一个伪数组对象, 这里调用相当于通过数组的索引来调用.
            // 这里 this 就是 指的这个伪数组, 所以 this.length 为 2
        }
    };
    obj.method(fn, 1, 2);    // 调用
</script>
原文地址:https://www.cnblogs.com/lph970417/p/11927424.html