new Operator

By: Dusty Arlia
Published on March 9, 2013
Last Updated on Sunday, July 12, 2015 at 3:17 PM
Total Updates: 5

Creates a new object. There are two different object types you can create with the new operator:

  • User-defined objects
  • Built-in objects (for example: function)

Here is the basic syntax for a statement using the new operator:

new [constructor]([arguments])

In the code above, the constructor is a function that specifies the type of the object. function is an example of a constructor, because all functions are actually objects. Next, arguments is a list of values. These are the values that the constructor will be called with.