※ 引述《peanut97 (丁丁)》之銘言:
: 小弟在看Facebook教學頁面學習React.js
: 常常看到bind寫法。
:
: ref:
: https://facebook.github.io/react/docs/thinking-in-react.html
: google了一下,依然有看沒有懂。
: 請問有簡單解釋bind的教學頁面嗎?
理論上這應該到 ajax 版問啦...
var mybaseFunction = function(str1,str2){
this.log(str1,str2);
}
var consoleHelloFunction = mybaseFunction.bind(console,"Hello");
/*
上面這行等價於
consoleHelloFunction = function(str){
return mybaseFunction.apply(console,["Hello",str]);
}
*/
consoleHelloFunction("world");