Skip to main content

this 的用法

1.this指向

a.硬绑定:bind、call、apply,如果第一个参数不为null或空,指向指定对象,否则非严格模式下执行window或global

b.new绑定:指向构造函数

c.隐式绑定,通过对象间接调用函数,指向调用点

e.箭头函数指向外层this

d.默认绑定:默认绑定指向window或global

参考

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions_and_function_scope

http://javascriptplayground.com/blog/2012/04/javascript-variable-scope-this/

http://www.ruanyifeng.com/blog/2010/04/using_this_keyword_in_javascript.html

http://www.nowamagic.net/librarys/veda/detail/1643

http://www.windguo.com/javascript/182.html

http://www.cnblogs.com/birdshome/archive/2005/03/07/95931.html

http://www.paulirish.com/2010/10-things-i-learned-from-the-jquery-source/