Scope of “this” in JavaScript

后端 未结 4 1947
春和景丽
春和景丽 2021-01-05 03:27

I have a JavaScript class that looks like this:

function SomeFunction()
{
    this.doSomething(function()
    {
        this.doSomethingElse();
    });

             


        
4条回答
  •  暖寄归人
    2021-01-05 04:17

    It's also worth mentioning that the next version of ECMAScript (the language spec for JavaScript) is going to introduce Function.bind(), which will let you specify a permanent context for a function.

提交回复
热议问题