我是JavaScript bind()
的新手,我想构建一个占位符函数。原始回调函数如下:
function fn(event, data1, data2){
console.log(data1, data2);
}
我尝试构建占位符函数,如:
var fn_bind = fn.bind(null, undefined, undefined, "data2");
稍后我想打电话给fn_bind("event", "data1")
打印
"data1", "data2"
但它一直在给我
undeinfed," data2"
有什么想法吗?