Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
class Animal {
    constructor (name, fly=false, sound) {
        this.name = name
        this.fly = fly
        this.sound = sound
    }
    canFly (fly) {
      if(this.fly) {
        return 'goes up up in the sky'
      }
      return 'stays on the ground'
    }
    talk (sound) {
      return this.sound;
    }
    describe () {
console.log(`${this.name}
${this.canFly()}
and shouts '${this.talk()}'`)
    }
}
class Cat extends Animal {
    constructor() {
        super()
        this.name = 'cat'
        this.fly = false
        this.sound = 'miao'
    }
}
class Bird extends Animal {
    constructor() {
        super()
        this.name = 'bird'
        this.fly = true
        this.sound = 'tchirp'
    }
}
var bird = new Bird()
var cat  = new Cat()
bird.describe()
cat.describe()
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
escapedcatpro
0viewers