This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

new

Summary

Creates a new object.

Syntax

new constructor ([ arguments ])
constructor
Required. The constructor of the object. The parentheses can be omitted if the constructor takes no arguments.
arguments
Optional. Any arguments to be passed to the new object’s constructor.

Examples

These are examples of valid uses of the new operator.

my_object = new Object;
my_array = new Array();
my_date = new Date("Jan 5 1996");

Remarks

The new operator performs the following tasks:

  • It creates an object with no members.
  • It calls the constructor for that object, passing a pointer to the newly created object as the this pointer.
  • The constructor then initializes the object according to the arguments passed to the constructor.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article