// ##FE通过call apply 借调其他函数FF // * 当FF为构造函数的时候,FE继承了FF的实例属性以及实例方法 // * 当FF为普通函数的时候,FE调用它,但FF的context变成了FE var A = function () { console.log('executing A'); this.name = "I\'am A"; this.sayName = function () { console.log('hello, ' + this.name); } }; A.prototype.protoMethod1 = function () { console.log("this is A' prototype method"); }; A.staticMethod1 = function () { console.log('this is A\' static method'); } var B = function () { A.call(this); };
典型应用
Array.prototype.slice.call(this, [start], [end])
[].slice.call(this, [start], [end])