The most viewed posts

Registry Reviver

Contact Me

Web Development Services

Computer Repair and Maintenance Service

How to clean up Windows Computer

Driver Booster

Myanmar font and keyboard for Windows

About Desktop Icons in Windows Computer

CCleaner

How to make a computer secure and run faster

The most viewed items

Dell Inspiron 5559

SONY Playstation Portable

Desktop Hard Disk

Laptop RAM

HP ProBook 430

Laptop

External Hard Disk

Please login to start chat

ZilaStar ICT Jun 14 2022, 08:04:31
Category : JavaScript Tutorials

Inheritance (JS Classes)

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo">Inheritance Test</p>
<script>
class Car{
constructor(brand){
this.carname = brand;
}
present(){
return "I have " + this.carname;
}
}

class Model extends Car{
constructor(brand, mod){
super(brand);
this.model = mod;
}
show(){
return this.present() + " and the model is " + this.model + ".";
}
}
var myCar = new Model("Tesla", "2021");
document.getElementById("demo").innerHTML = myCar.show();
</script>
</body>
</html>

  • Comments:

    No comment.

    To Contact
    Available Services
    Terms and Conditions