Skip to content

Instantly share code, notes, and snippets.

@ioxua
Last active December 23, 2018 20:06
Show Gist options
  • Save ioxua/207c0ef0f4f4dabbbccc496d1a262829 to your computer and use it in GitHub Desktop.
Save ioxua/207c0ef0f4f4dabbbccc496d1a262829 to your computer and use it in GitHub Desktop.
Dwemthy's Array ES6 -- medium post 1
class Creature {
constructor() {
this.traits("life", "strength", "charisma", "weapon");
}
traits(...args) {
args.forEach(name => {
Object.defineProperty(this, name, {
writable: true
});
});
}
// Omitted a LOT of methods here.
}
class Rabbit extends Creature {
constructor() {
super();
this.traits("bombs");
this.bombs = 3;
this.life = 10;
this.strength = 2;
this.charisma = 44;
this.weapon = 4;
this.bombs = 3;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment