this
来源:互联网 发布:java开发人员简历 编辑:程序博客网 时间:2024/06/05 15:40
1、js中this代表什么?
this代表当前执行的上下文。
var name = "window";var F = function(){ console.log("this.name=%s", this); //window}
F()
执行f函数的时候发现输出的是window,因为f这个是由window来调用的。
但是当我们使用 var f = new F(); 这个this对象指向的确是f这个对象。因为f是一个独立的上下文执行环境。
2、如何改变一个函数this的指向?
js中提供了apply与call两种方式来改变。
例如:
0 0
- this
- this
- this
- this
- this
- this
- this
- this
- this
- this
- this
- $(this)
- this
- this
- this
- this
- $(this)
- this
- Oracle redo log 大小及组数的设置(在线修改日志组数目及组成员个数)
- VS2015密匙
- 如何旋转至面向某个物体
- iOS证书
- 决战Offer---操作系统
- this
- 查看Oracle的redo日志切换频率
- python多线程threading.Lock锁实例
- c语言之堆,栈,队列
- Android初试--Activit的简单介绍(1)
- 内部类详解
- ORACLE AWR报告之 log file sync等待事件优化的总结【转自ITPUB】
- 浅谈try catch finally
- 基础练习 回文数