Skip to content

Instantly share code, notes, and snippets.

@ancms2600
Last active March 15, 2018 19:04
Show Gist options
  • Save ancms2600/f7917373355c4be03b688544416a72bf to your computer and use it in GitHub Desktop.
Save ancms2600/f7917373355c4be03b688544416a72bf to your computer and use it in GitHub Desktop.
lol shorthand es6 class syntax
// 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