English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
' extends 'keyword is used to createClass inheritance. It hasClass inheritancerelationshipclassinherits from anotherClassAll methods. Let's discuss briefly.
In the following example, " extends "keyword is used to pass properties from"Company"Class"Inheritance to "Model"Class. super" () Method reference父 Class. The method called in the constructor method is just calling the constructor method of the parent object, and can access the properties and methods of the parent object.super()
<html> <body> <p id="method"></p> <script> class Company { constructor(branch) { this.name = branch; this.model; method() { return this.name + " has a product that is "; this.model; this.model; class Model extends Company { constructor(branch, pname) { super(branch); this.model = pname; result() { } + return this.method(); + " " this.model; this.model; }3mycar = new Model("w codebox, "Tutorix"); </document.getElementById("method").innerHTML = mycar.result(); </body> </html>
w3codebox has a product that is Tutorix