The new Keyword in JavaScript: How Objects Are Created Behind the Scenes
what is new key word? where it use? how it works behind the sean?

If you've ever used JavaScript constructors or classes, you've probably used the new keyword. But what exactly does it do?
At first glance, new looks simple but behind the scenes, it performs a series of important steps that bring objects to life.
In this article, we’ll break it down in a simple, human-friendly way.
What Does the new Keyword Do?
The new keyword is used to create an instance of an object from a constructor function.
In simple terms: It creates a fresh object and connects it to a blueprint (constructor).
Constructor Functions
A constructor function is just a regular function used to create multiple objects with similar structure.
Example:
function Person(name, age) {
this.name = name;
this.age = age;
}
Now we use new:
const user1 = new Person("Nikhil", 22);
console.log(user1);
Output:
{
name: "Nikhil",
age: 22
}
Step-by-Step: What Happens When You Use new?
When you write:
const user1 = new Person("Nikhil", 22);
JavaScript internally does this:
Step 1: Create an Empty Object
let obj = {};
Step 2: Link Prototype
obj.__proto__ = Person.prototype;
Step 3: Bind this
Person.call(obj, "Nikhil", 22);
Step 4: Return the Object
return obj;
So new is basically doing all of this automatically.
How new Links Prototypes
Every constructor function has a prototype property.
When you use new, the created object is linked to that prototype.
Example:
Person.prototype.greet = function () {
console.log(`Hello, my name is ${this.name}`);
};
const user1 = new Person("Nikhil", 22);
user1.greet();
Output:
Hello, my name is Nikhil
Even though greet() is not inside the object, it works because of prototype linking.
Instances Created from Constructors
Each object created using new is called an instance.
const user1 = new Person("Nikhil", 22);
const user2 = new Person("Rahul", 25);
Both are different objects But they share the same prototype
Real-Life Analogy
Think of a constructor as a factory blueprint
Constructor = blueprint
new= machine creating productObject = final product
Constructor → Instance Flow
Prototype Linking
Common Mistakes
Forgetting new
const user1 = Person("Nikhil", 22);
This will NOT create an object properly this may point to global object (or undefined in strict mode)
Overwriting Prototype
Person.prototype = {
greet: function () {}
};
This removes the default constructor reference
Constructor vs Class (Quick Note)
Modern JavaScript uses classes:
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
But internally, it still uses new and prototypes!
Conclusion
The new keyword is more than just syntax it’s a process:
-Creates a new object
-Links it to a prototype
-Binds this
-Returns the object
Understanding this helps you truly master how JavaScript works under the hood.





