The new Keyword in JavaScript

What is new keyword
new keyword is used to create instances from the constructor functions.
What the new keyword does
new keyword does four things when used with constructor function
1) Create an Empty Object ====> const obj = {};
2) Function and Object prototype is linked ====> obj.__proto__ = Car.prototype;
3) bind Car with obj ====> Car.bind(obj, 'BMW', 2015);
4) Returns that object automatically ====> return obj;
Constructor functions
This is used to create(construct) multiple instances from this function
Object creation process
function Airline(name){
this.name = name;
}
const indigo = new Airline('Indigo');
How new links prototypes
new keyword overwrite the object prototype with the prototype of the function.
We generally add methods to the prototype of the function because new keyword wil give reference of function prototype




