Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no" />
    <title>Learning React Chapter 2 Samples</title>
  </head>
  <body>
    <h1>Open the Console</h1>
  </body>
</html>
 
// Inheritance
class Vacation {
  
  constructor(destination, length) {
    this.destination = destination
    this.length = length
  }
  
  print() {
    console.log(`${this.destination} will take ${this.length} days.`)  
  }
  
}
class Expedition extends Vacation {
  
  constructor(destination, length, gear) {
   super(destination, length)
   this.gear = gear
  }
  
  print() {
    super.print()
    console.log(`bring your ${this.gear.join(" and your ")}`)
  }
}
const trip = new Expedition(
  "Mt. Whitney", 
  3, 
  ["sunglasses", "prayer flags", "camera"]
)
trip.print()
Output

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

Dismiss x
public
Bin info
moonhighwaypro
0viewers