Call, Apply, Bind
Call 和 Apply
var numbers = [5, 458 , 120 , -215 ];
var maxInNumbers = Math.max.apply(Math, numbers), //458
maxInNumbers = Math.max.call(Math,5, 458 , 120 , -215); //458function log(){
console.log.apply(console, arguments);
};
log(1); //1
log(1,2); //1 2Bind
对比
实现
Bind
ES5 实现
ES6 实现
Call
call 第二种实现方式
Apply
apply 第二种实现方式
最后更新于