Article From:

GOAttribute, variable declarative it needs special attention here.:

  • in the global variable declaration must bevar Keyword variable declaration, let and const in ES6 do not increase variables.
  • function of the song body must befunctionA function that is defined by a keyword;
  • Variables without any key in the function body are also promoted to global objects.
  • The function’s permission is greater than the variable. When the same name, the function overrides the variables and does not appear before and after the sequence.



When the function and the variable are named GO execution context context ),AOObject;

  • functionThe function defined by the key is defined as the attribute of the AO object and the attribute value is the function body.
  • After the function is executed, it destroys its execution period context.
  • What needs to be paid special attention here is:

    Arguments and formal values are unified before the keyword function, and the permissions of functions are larger than variables. Therefore, formal parameters and subfunctions are covered when they are named.



    Next, let’s understand the scope chain in detail:

    First, copy the first sentence of this article.” global function in the song body.GOPut your own scope and execute it on your own AO.

    scopeScope has been stored in the parent level, and when the parent’s execution completes the execution context, it does not work for the returned function, because one of its own scope has been backed up. So the returned function can access its parent variables.

    Leave a Reply

    Your email address will not be published. Required fields are marked *