Operators

new operator

Try the free JavaScript compiler

Invokes a constructible value. Ordinary base constructors create a receiver, and an explicitly returned object can replace it; primitive returns are ignored for ordinary base constructors. Nonconstructible values throw.

Formal Syntax & Structure

javascript syntaxjavascript
new Constructor(...args)

Parameters & Attributes

NameTypeDescription
ConstructorConstructorConstructible target.
argsAny[]Constructor arguments.

Return Value

Object

Construction result.

Working Example

Example Snippetjavascript
function Box(n){this.n=n;}console.log(new Box(3).n);
JavaScript Reference