Last active
March 15, 2018 19:04
-
-
Save ancms2600/f7917373355c4be03b688544416a72bf to your computer and use it in GitHub Desktop.
lol shorthand es6 class syntax
This file contains 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
// LOL! Look at this... | |
// This class syntax is very shorthand, inline, and anonymous. | |
// However I'm skeptical that the runtime interpreter is able to optimize it | |
// like traditional class semantics. | |
// class | |
const State = () => ({ | |
// constructor | |
object: {}, | |
array: [], | |
ns: [], | |
// another class | |
branch: (_this => Object.assign(_this, { | |
// instance methods | |
wrap: (key) => _this = { [key]: _this }, | |
prepend: (nodeOrBranch) => _this.unshift(nodeOrBranch), | |
}))([]), | |
}); | |
// WHY would anyone do this? | |
// NOT recommended. | |
// Just lazy. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment