this in [removed]:Japanese_symbol_for_beginner:学习JavaScript中“ this”的概念! [五个概念]
的概念this在JavaScript TL; DR 如果一个函数被调用使用new关键字, this将是生成的对象。 如果一个函数被调用, .call() .apply()或.bind() this将是在传递的对象。 如果一个函数被调用的对象上, obj.foo() this将是它被称为上的对象。 如果一个函数自己说sayMyName() , this它将是undefined (如果use strict;模式)或全局对象(如果是非严格模式)。 概念#1 如果一个函数被调用使用new关键字, this将是生成的对象。 let myName = new String ( 'Ahmad Awais' ) ; typeOf ( myName ) ; // object <================== this is the resulting object. 概念#2 如果一个
下载地址
用户评论