相关疑难解决方法(0)

什么对象javascript函数绑定(它的"this"是什么)?

我知道它在函数内部this.

var func = function {
    return this.f === arguments.callee; 
    // => true, if bound to some object
    // => false, if is bound to null, because this.f === undefined
}

var f = func; // not bound to anything;

var obj = {};
obj1.f = func; // bound to obj1 if called as obj1.f(), but not bound if called as func()

var bound = f.bind(obj2) // bound to obj2 if called as obj2.f() or as bound()
Run Code Online (Sandbox Code Playgroud)

编辑: …

javascript functional-programming function this ecmascript-5

19
推荐指数
2
解决办法
9098
查看次数