JavaScriptEasy
What is the purpose of the new keyword?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
The new keyword in JavaScript is used to create an instance of a user-defined object type or one of the built-in object types that has a constructor function. When you use new, it does four things: it creates a new object, sets the prototype, binds this to the new object, and returns the new object.
js
function Person(name) {
this.name = name;
}
const person1 = new Person("Alice");
console.log(person1.name); // Alice
