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

Publicado el: 02 septiembre 2021
en el canal de: Tech Gun
64,604
1.5k

#Javascript #Tutorial #Hindi

Link for Complete JavaScript Tutorial in Hindi for Beginners:    • JavaScript Tutorial in Hindi  

Link for Complete HTML and CSS Tutorial in Hindi for Beginners:    • Playlist  


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:    / @techgun  


En esta página del sitio puede ver el video en línea Advanced JavaScript Tutorial in Hindi [Part 91] - Prototype and Prototypal Inheritance in JavaScript de Duración hora minuto segunda en buena calidad , que subió el usuario Tech Gun 02 septiembre 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 64,604 veces y le gustó 1.5 mil a los espectadores. Disfruta viendo!