javascript this的意思

this指向哪里?

一般而言,在Javascript中,this指向函数执行时的当前对象。

In JavaScript, as in most object-oriented programming languages, this is a special keyword that is used within methods to refer to the object on which a method is being invoked.

——jQuery Fundamentals (Chapter 2), by Rebecca Murphey

值得注意,该关键字在Javascript中和执行环境,而非声明环境有关。

The this keyword is relative to the execution context, not the declaration context.

 

 

 

作为函数调用时,this 绑定到全局对象;作为方法调用时,this 绑定到该方法所属的对象。

 

可参考下面这个文章

 

http://www.cnblogs.com/justany/archive/2012/11/01/the_keyword_this_in_javascript.html

http://www.ibm.com/developerworks/cn/web/1207_wangqf_jsthis/

http://yehudakatz.com/2011/08/11/understanding-javascript-function-invocation-and-this/?cm_mc_uid=10332690919714457452748&cm_mc_sid_50200000=1445838114

转载于:https://www.cnblogs.com/terryc/p/4910832.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值