Advanced JavaScript Tutorial in Hindi [Part 91] - Prototype and Prototypal Inheritance in JavaScript

Tech Gun
Youtube
Related Topic
:- Javascript

#Javascript #Tutorial #Hindi Link for Complete JavaScript Tutorial in Hindi for Beginners: https://www.youtube.com/playlist?list=PLjpp5kBQLNTSvHo6Rp4Ky0X8x_MabmKye Link for Complete HTML and CSS Tutorial in Hindi for Beginners: https://www.youtube.com/playlist?list=PLjpp5kBQLNTSdLVVjU_kea8J8lP24ZseT In this video i will talk about Prototype and Prototypal Inheritance in Javascript. In programming, we often want to take something and extend it. All JavaScript objects inherit properties and methods from a prototype. A JavaScript prototype is used to add new properties and methods to an existing object constructor. All JavaScript objects inherit properties and methods from a prototype: Date objects inherit from Date.prototype. Array objects inherit from Array.prototype. Player objects (from the example above) inherit from Player.prototype. The Object.prototype is on top of the prototype inheritance chain; ​ Date objects, Array objects, and Player objects all inherit from Object.prototype. For instance, we have a user object with its properties and methods, and want to make admin and guest as slightly modified variants of it. We’d like to reuse what we have in user, not copy/reimplement its methods, just build a new object on top of it. Prototypal inheritance is a language feature that helps in that. If you’ve worked with other object-oriented programming languages such as Java or C++, you’ve been familiar with the inheritance concept. In this programming paradigm, a class is a blueprint for creating objects. If you want a new class to reuse the functionality of an existing class, you can create a new class that extends the existing class. This is called classical inheritance. JavaScript doesn’t use classical inheritance. Instead, it uses prototypal inheritance. In prototypal inheritance, an object “inherits” properties from another object via the prototype linkage. Please subscribe to watch more videos like this: https://www.youtube.com/channel/UCWCGvAu1NDCldmLasELk62g?sub_confirmation=1

Comments