this 三句话

1. this 默认是 window
2. 只能通过 .call 、 .apply 来指定 this
3. fn() 等价于 fn.call() ;  obj.fn() 等价于 obj.fn.call(obj) 
 
function fn(){
    console.log(this.length);
}
var obj = {
    length:5,
    method:function(fn){
        arguments[0]();
        fn();
    }
}
obj.method(fn,1)// 2,0

 

posted @ 2016-09-20 21:32  怪到抽筋  阅读(90)  评论(0编辑  收藏  举报