ke3863834的博客通过本文主要向大家介绍了函数,对象,继承等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
call函数的描述:写一个方法,然后让另外一个新的对象来继承它(而不是在新对象中再写一次这个方法)。
this.x = 9;
var module = {
x: 81,
getX: function() { return this.x; }
};
module.getX(); // 返回 81
var retrieveX = module.getX;
retrieveX(); // 返回 9, 在这种情况下,”this”指向全局作用域
fun.call(thisArg[, arg1[, arg2[, …]]])
参数:thisArg
在fun函数运行时指定的this值。需要注意的是,指定的this值并不一定是该函数执行时真正的this值,如果这个函数处于非严格模式下,则指定为null和undefined的this值会自动指向全局对象(浏览器中就是window对象),同时值为原始值