-
-
Save shahab570/1d57c17ab076d765654e080e8826a77d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
constructor(name) { | |
this.name = name; | |
} | |
sayHi() { | |
console.log("Hi I am", this.name, " I am a human"); | |
} | |
} | |
class Robot extends Person { | |
constructor(name) { | |
super(name); | |
} | |
sayHi() { | |
console.log("Hi I am", this.name, " I am a robot"); | |
} | |
} | |
let person = new Person("John smith"); | |
let sofia = new Robot("SOFIA"); | |
person.sayHi(); //Hi I am john smith, I am a human | |
sofia.sayHi(); //Hi I am SOFIA , I am a robot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment