Function.bind
你可以利用 function.bind
來改變呼叫函式的對象(this):
JS Bin
try starck.callBySelf();
or starck.callByWindow();
in console.
function.bind
For a given function, creates a bound function that has the same body as the original function. In the bound function, the this object resolves to the passed in object. The bound function has the specified initial parameters.
function.bind(thisArg[,arg1[,arg2[,argN]]])
Callback 的應用:
JS Bin
try starck.say('hi')