Talking about the use of JavaScript and constructor of this

 

What is the constructor: In JavaScript, a  new function key to call the called constructor.

Its role: required repeated attribute parameters passed as a constructor can reduce the number of repeated operations.

In use, if the new forget to use, it will have serious consequences. The constructor will lead to an internal variable becomes a global variable.

The method avoids using strict mode inside the constructor.

When an error occurs, it will terminate js. At this point you can be modified according to debug error.

 

 

What this is

 

Before understanding this, to correct a point of view, this point is neither the function itself, does not refer to the lexical scope of a function. If only the English interpretation of this, too misleading. It is actually binding occurs only when the function is called, that is what this particular point, depending on how you function call.

this call:

Who calls who point

If assigned to the object, this will change the point of

Not in the first layer will not inherit call up

Guess you like

Origin www.cnblogs.com/CWJDD/p/10983656.html