How to Implement Inheritance in JavaScript | Function Constructor Inheritance in JavaScript

Veröffentlicht am: 09 January 2023
auf dem Kanal: NomadCoder
1,243
44

This video explains how to implement Inheritance in JavaScript. The implementation of Inheritance depends on how objects are created; for instance, inheritance between two object literals is implemented differently than inheritance between function constructors.


The video explains you to implement inheritance in function constructors. To do that, you follow two steps,


Call the parent function constructor indirectly using call or apply the method to assign the common properties.




function Dog(family,name, age){


Animal.call(this,name,age);
this.family = family;
}




Link the prototype of the child function constructor to the prototype of the parent function constructor




Object.setPrototypeOf(Dog.prototype,Animal.prototype);


Please let me know in the comments your feedback and questions.


Auf dieser Seite können Sie das Online-Video How to Implement Inheritance in JavaScript | Function Constructor Inheritance in JavaScript mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer NomadCoder 09 January 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,243 Mal angesehen und es wurde von 44 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!