js: Since calling (self-executing) function

(function(){

  return .....

 })()

 

For example:

 

 

js call self (self-executing) the wording of two commonly used functions (and possibly other wording):

1, ( function (shape attended table) {

    return .....

  } ) (Argument list);

 

2, ( function (shape attended table) {

    return .....

  } (Argument list) ) ;

 

const constants defined in the self-calling function in the outside world are not visit, because the scope is limited to the constant calls from internal function; and, in the call from the external function call from the calling function is not acceptable. Because since the calling function, by definition, can only refer to itself at the same time once defined! Not visible to the outside world.

 

If, from the external function call, since the call wants to access function returns a variable (object), may not be used const XXX = {xxx: xxx}; used: Window.XXX = {.....};

E.g:

 

 In this way, since the external function call, you can use the Wiindow.XXXX.

Guess you like

Origin www.cnblogs.com/JAVA-STUDYER/p/11587309.html