This project is a reference corpus for exploring similarities and differences in conventional JavaScript inheritance ("Naive"), ES6 Classes ("Classes"), as well as an example of trying to ape classes ("Sugarfree"). It consists of a chart of JavaScript property descriptors where comparison is possible, and of reference implementations of class-like structures/systems, in:
- ES6 classes
- naive construction usage
- naive prototype extending via
Object.create
- Sugarfree "ES6 emulation-mode"
- ES6 extend which PropertyDescriptor wise looks identical to ES6 Classes
writable | enumerable | configurable | value | diff from default if prop | |
---|---|---|---|---|---|
Things we can do something about | |||||
Default defineProperty {value} | false | false | false | value | |
Naive.prototype.bing | false | false | false | [Function: bing] | |
Classes.prototype.bing | true | false | true | [Function: bing] | {enumerable:true,value} |
Classes.singleton | true | false | true | [Function: singleton] | {enumerable:true,configurable:true,value} |
Language behavior | |||||
Classes.prototype | false | false | false | Classes{} | |
Naive.prototype | true | false | false | {} | |
NaiveExtend.prototype | true | false | false | NaiveExtend {constructor: NaiveExtend} | |
Classes.protype.constructor | false[1] | false | true | [Function: Classes] | |
Naive.prototype.constructor | true | false | true | [Function] | |
NaiveExtend.prototype.constructor | true | true | true | [Function: NaiveExtend] |
[1] node v5.10 does not reflect this setting
This is possible and provoked by seeing, and the desire to get a quick/fast code reference for it.
Preview of next release of “Exploring ES6” (@exploringjs): the attributes of properties created by classes.
— Axel Rauschmayer, https://twitter.com/rauschma/status/718868475100413953
I am seeking ways to recreate objects with closer parity (in the language behaviors section) to Classes, without using ES6 Classes.