控制台执行下面
function getConfig(color,size,otherOptions){
console.log(color,size,otherOptions);
}
var defaultConfig = getConfig.bind("#FFF","20*12");
defaultConfig ('123')
输出20*12 123 undefined
请问输出的20*12 123 undefined
是什么原理?为什么下面的语句正常输出
function getConfig(color,size,otherOptions){
console.log(color,size,otherOptions);
}
var defaultConfig = getConfig.bind(null,"#FFF","20*12");
defaultConfig ('123')
输出#FFF 20*12 123
.bind
第一个参数为null
时,后面的参数为什么自动对应getConfig
的前两个参数?
bind
的第一个参数是做为原函数的this
指向的,第二个参数开始才是函数的参数可以去看下这篇文章:https://developer.mozilla.org...