Skip to content

Instantly share code, notes, and snippets.

@mageowl
Created March 30, 2021 23:56
Show Gist options
  • Save mageowl/a9c6dede24aa3ec16852ac1e808a630f to your computer and use it in GitHub Desktop.
Save mageowl/a9c6dede24aa3ec16852ac1e808a630f to your computer and use it in GitHub Desktop.
Syntactic sugar.
class Property {
constructor(name, value) {
this.arr = [name, value];
}
}
class Name extends Property {
constructor("name", "Owen") // static constructor, values are passed directly to "super".
/*
constructor() {
super("name", "Owen")
}
*/
change(value) {
this.arr = ["name", value]
}
}
let myName = new Name();
myName.arr // ["name", "Owen"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment