Constructor Chaining

Learning from AstroPlatformer

Code Runner Challenge

constructor-chaining

View IPYNB Source
%%js
// CODE_RUNNER: constructor-chaining

class Coin {
  constructor(id, x) {
    this.id = id; this.x = x;
  }
}
class GameCoin extends Coin {
  constructor(id, x, value) {
    super(id, x);
    this.value = value;
  }
}
const c = new GameCoin("c1", 90, 1);
console.log(c);

Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...