Skip to content

Instantly share code, notes, and snippets.

@raduGaspar
Created April 1, 2019 18:39
Show Gist options
  • Save raduGaspar/52297cfdb77f1c2dbf2c8e506928d772 to your computer and use it in GitHub Desktop.
Save raduGaspar/52297cfdb77f1c2dbf2c8e506928d772 to your computer and use it in GitHub Desktop.
class Person {
constructor (firstName, lastName, birthday) {
this.firstName = firstName
this.lastName = lastName
this.birthday = birthday
}
sayHello () {
return `My name is ${this.firstName}`
}
}
class SuperGirl extends Person {
constructor (firstName, lastName, birthday, superpowers) {
super(firstName, lastName, birthday)
this.gender = 'female'
this.superpowers = superpowers
}
fly () {
return 'I can fly'
}
}
const sg = new SuperGirl('Kara', 'Zor-El', 1554143709, [
'flying', 'heat vision', 'strength'
])
console.log(sg.sayHello(), sg.fly())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment