0
다른 함수에 일반적인 구성 인수를 적용하는 래퍼 함수를 만들고 싶지만 fn
함수에 var config
을 추가하는 방법을 모르겠습니다.일반 구성을 다른 함수로 전달하는 래퍼 함수
function addConfig(val, fn) {
var config = { value: val };
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(config);
return fn.apply(this, args)
}
}
function test(id, name, config) {
console.log(arguments);
}
addConfig('a', test(1, 'bill')); // Does not log out config object