摘要: 在写js的时候,我们往往会遇到this的概念,this的指向,总会让人很头痛。今天根据我对this的理解,和一些经验,来用一句话总结下this。那么这句话就是: this在有函数调用者时指向调用者否则指向GLOBAL,call、apply除外。 那么,我们通过一个例子来理解并记住这句话: 1 function test(){ 2 console.log(this); 3 } 4 test();//Window 5 var th = {}; 6 test.call(th)//th 7 test.apply(th)//th 8 var a = function(){ 9 }... 阅读全文
posted @ 2012-09-05 23:03 毛绒猫猫 阅读(2070) 评论(1) 推荐(3) 编辑