博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js中this的使用
阅读量:4485 次
发布时间:2019-06-08

本文共 507 字,大约阅读时间需要 1 分钟。

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);
 

 

转载于:https://www.cnblogs.com/mttcug/p/8473936.html

你可能感兴趣的文章
JSP
查看>>
Time, Clocks, and the Ordering of Events in a Distributed System
查看>>
C#成员基础
查看>>
字符设备 register_chrdev_region()、alloc_chrdev_region() 和 register_chrdev()
查看>>
为Azure Web Site 添加ADFS验证支持之二 在代码里使用ADFS
查看>>
day1--计算机基础1
查看>>
phpStudy
查看>>
编程珠玑——第一章习题
查看>>
mapper.xml文件中标签不显示问题
查看>>
JavaScript的事件
查看>>
ios中实现对UItextField,UITextView等输入框的字数限制
查看>>
PAT Basic 1008
查看>>
[Information Theory] L1: Introduction to Information Theory
查看>>
相册分类列表页
查看>>
各浏览器的鼠标位置测试
查看>>
[BZOJ1070][SCOI2007]修车(最小费用最大流)
查看>>
python字节码(转)
查看>>
[bzoj 2151]种树(贪心)
查看>>
js函数
查看>>
Unity3D 之UGUI 图片
查看>>