JavaScript Tutorial in Hindi for Beginners [Part 32] - "new" Keyword in JavaScript

Tech Gun
Youtube
Related Topic
:- Web Development Javascript

In this video i will talk about "new" Keyword in JavaScript. The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function. The new keyword does the following things: 1. Creates a blank, plain JavaScript object. 2. Adds a property to the new object (__proto__) that links to the constructor function's prototype object 3. Properties/objects added to the construction function prototype are therefore accessible to all instances created from the constructor function (using new). 4. Binds the newly created object instance as the this context (i.e. all references to this in the constructor function now refer to the object created in the first step). 5. Returns this if the function doesn't return an object.

Comments