daily log 11.15.20
ES6 Classes Review
class Cat {
constructor(options){
this.paws = 4;
this.whiskers = "yes"
}
meow(){
return 'meow meow meow'
}
}
var my_cat = new Cat
my_cat.paws
my_cat.whiskers
my_cat.meow()
Extending class Cat
class Cat {
constructor(options){
this.name = options.name;
this.whiskers = "yes"
}
meow(){
return 'meow meow meow'
}
}
var my_cat = new Cat({ name: 'Tonks' })
my_cat.whiskers
my_cat.name
my_cat.meow()
class Pippin extends Cat {
constructor(options){
super(options)
this.mood = 'Moody'
}
}
var pippin = new Pippin({ name: 'Peep' })
pippin.mood
pippin.name
pippin.meow()