Operators
new operator
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
| Name | Type | Description |
|---|---|---|
| Constructor | Constructor | Constructible target. |
| args | Any[] | Constructor arguments. |
Return Value
Object
Construction result.
Working Example
Example Snippetjavascript
function Box(n){this.n=n;}console.log(new Box(3).n);