liveBook · Manning

New keyword

In JavaScript, new is an operator that creates an object instance by invoking a constructable function or class as its constructor.

How 2 Manning books explain it

Secrets of the JavaScript Ninja, Second Edition

A JavaScript operator that creates an object instance and invokes a constructor function with that object as its this value.

How it is used
Creates and initializes object instances by invoking functions as constructors.
How deep it goes
Explains object creation, `this`, prototype linkage, and return-value exceptions through contrasting calls and examples.
Examples
Contrasts ordinary and constructor calls, constructs two objects with methods, and tests primitive and object returns.
What you can do after
Build it from scratch: initialize instances with `new` and make methods available through a constructor's prototype.

Read how Secrets of the JavaScript Ninja, Second Edition explains new keyword →

The Joy of JavaScript

The JavaScript operator keyword that creates a new object instance by invoking a constructor function or class.

How it is used
Instantiates constructor-based objects and enables shared prototype behavior.
How deep it goes
Explains prototype links, constructor references, method sharing, and safeguards against improper calls.
Examples
Uses Transaction and HashTransaction instances, shared methods, TypeErrors, new.target, and Object.create prototype configuration.
What you can do after
Apply it via constructor functions to create instances with shared prototype methods and safer invocation behavior.

Read how The Joy of JavaScript explains new keyword →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.