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

Показать описание
#Javascript #Tutorial #Hindi
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:
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.
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:
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.
Комментарии