Home > front end >  The structure of the JavaScript function
The structure of the JavaScript function

Time:10-16

Constructor is divided into the constructor of the system (such as the Date) and custom constructor, it calls need to achieve with the new, a call to a constructor, can create an object in memory,
Both the constructor of the system and the custom of the constructor, the invocation style are the same, the Date, for example: see figure
Constructor can not directly as argument, to pass after the call to the incoming function,
Not so system custom object is the constructor, such as Math, Math is not a constructor, the inside there is a static member, so its invocation style is direct call, example:
PI calls -- Math. PI
Take the absolute value calls -- Math. Abs ()
As the Date, as a constructor, you can't direct call, call way:
Var d=new Date ();
The console. The log (d.g etDate);
  • Related