後で実行される関数を実装するカスタム オブジェクトがあります。誰かがそれを呼び出す方法は次のとおりです。
customObject.onSomething(function(e) {
// do something with e
console.log('foobar');
});
onSomething の作成方法は次のとおりです。
var CustomObject = function() {
this.onSomething = function(callback) {
// If the user passes in parameter(s), how can I modify them before calling?
callback.apply(this);
}
}
関数で適用または呼び出しを実行する前に、ユーザーが渡した引数を変更するにはどうすればよいですか?