this,你这么调皮,函数麻麻知道嘛?

来源:javascript高级程序设计

在几种特殊的情况下,this的值可能会意外改变。比如

var name="The Window";
var object={
   name:"The Object",
   getName:function(){
       return this.name;
   } 
};

object.getName();    //  "The Object"
(object.getName)();    //  "The Object"
(object.getName=object.getName)();    //  "The  Window"  在非严格模式下

 

posted @ 2015-08-26 16:44  四叶草黎  阅读(117)  评论(0编辑  收藏  举报