Skip to content

Instantly share code, notes, and snippets.

@krambuhl
Created December 4, 2015 07:59
Show Gist options
  • Save krambuhl/fa85e2d9cb49e889160a to your computer and use it in GitHub Desktop.
Save krambuhl/fa85e2d9cb49e889160a to your computer and use it in GitHub Desktop.
class Car {
options() {
return { truckmode: false, big: false };
}
static config(ops) {
return class extends this {
options() {
return Object.assign({}, super.options(), ops);
}
}
}
}
var Truck = Car.config({ truckmode: true });
var BigTruck = Truck.config({ big: true });
var civic = new Car();
var ranger = new Truck();
var mactruck = new BigTruck();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment