this一般指执行当前代码的所有者
一个小李子:
person.sayHello() //name is undefined sayHi()函数中的this此时代表的window或者global ,window下有name属性
person.sayHello()中的this代指的就是person对象了,person中无name属性
本文例句三种指针使用错误情况:
1.dom中的函数事件
alert(getCookie.call(Utility,"identity")); //alert(getCookie.apply(Utility,["identity"]));
} showUserIdentity(); script> 3.传参时导致指针丢失 注意,Javascript里面都是值传递的,没有引用传递的概念
var boundFunc = person.sayHi.bind(person,person.sayHi); setTimeout(boundFunc,5000);