Created
December 4, 2015 07:59
-
-
Save krambuhl/fa85e2d9cb49e889160a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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