Answers for "function inheritance in javascript"

1

javascript inheritance

class Car {
  constructor(brand) {
    this.carname = brand;
  }
  present() {
    return 'I have a ' + this.carname;
  }
}

class Model extends Car {
  constructor(brand, mod) {
    super(brand);
    this.model = mod;
  }
  show() {
    return this.present() + ', it is a ' + this.model;
  }
}

let myCar = new Model("Ford", "Mustang");
document.getElementById("demo").innerHTML = myCar.show();
Posted by: Guest on February-17-2022
3

javascript inheritance

class Animal {
   null
}
class tiger extends Animal {
 null }
Posted by: Guest on May-15-2021
0

Inheritance in JavaScript

class teamMember {
    name;
    designation = "Support web dev";
    address;
    constructor(name, address) {
        this.name = name;
        this.address = address;
    }
}

class Support extends teamMember {
    startSession() {
        console.log(this.name, "start a support sessin");
    }
}
class StudentCare extends teamMember {
    buildARoutine() {
        console.log(this.name, "build a routine");
    }
}

const max = new Support("Max", "USA");
console.log(max);
const sarah = new StudentCare("Sarah", "UK");
console.log(sarah);
Posted by: Guest on January-06-2022
1

javascript inheritance

class childClass extends parentClass
{
  
}
Posted by: Guest on September-02-2021
0

javascript inheritance

function Teacher(first, last, age, gender, interests, subject) {
  Person.call(this, first, last, age, gender, interests);

  this.subject = subject;
}
Posted by: Guest on February-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language