Properties the declarative way
const $frequency = Symbol.for("Overthruster:frequency") | |
export class Overthruster | |
{ | |
constructor({frequency}={}){ | |
this[$frequency]= frequency | |
} | |
get frequency(){ | |
return this[ $frequency] | |
} | |
} | |
// Things I like about this approach: | |
// * Object.getOwnPropertyDescriptor(Overthruster.prototype.frequency) returns something! There's some reflection! | |
// * Getter/setters can be extended using .super. | |
// * The underlying state is accessible, which to me is a major positive. User beware, but it's obvious you're going slightly far afield. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment