私はこの記事を読んでいます-http://www.robertsosinski.com/2009/04/28/binding-scope-in-javascript/ -カスタムバインド関数が作成されています。
Function.prototype.bind = function(scope) {
var _function = this;
return function() {
return _function.apply(scope, arguments);
}
}
alice = {
name: "alice"
}
eve = {
talk: function(greeting) {
console.log(greeting + ", my name is " + this.name);
}.bind(alice) // <- bound to "alice"
}
eve.talk("hello");
// hello, my name is alice
私の質問は、特にこの行です
return function() {
return _function.apply(scope, arguments);
}
_function.apply(scope、arguments);が返されるのはなぜですか。そこの?そして、それは何をしていて、何が返されているのでしょうか?私はそのリターンを削除しましたが、それでも機能します。