関数内から別の関数に引数を転送するにはどうすればよいですか?
私はこれを持っています:
function SomeThing(options) {
function callback(callback_name) {
if(options[callback_name]) {
// Desiring to call the callback with all arguments that this function
// received, except for the first argument.
options[callback_name].apply(this, arguments);
}
}
callback('cb_one', 99, 100);
}
引数で得られるのa
は「cb_one」ですが、「99」にしてほしいです。
var a = new SomeThing({
cb_one: function(a,b,c) {
console.log(arguments); // => ["cb_one", 99, 100]
console.log(a); // => cb_one
console.log(b); // => 99
console.log(c); // => 100
}
});
どうすればいいですか?