← Back to Roadmap

new Keyword

Medium

In plain terms

new creates an object, sets its prototype, runs constructor with this bound to the new object, returns it. Used with constructor functions and classes.

What you need to know

  • Creates object
  • Binds this
  • Runs constructor

Try it yourself

Copy the code below and run it in your browser console or a code editor:

function Person(n) { this.name = n; } const p = new Person('Alice'); p instanceof Person; // true

Learn more

Dive deeper with these trusted resources: