Skip to content

Instantly share code, notes, and snippets.

@zenparsing
Last active September 17, 2015 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenparsing/11326f4677f772a81392 to your computer and use it in GitHub Desktop.
Save zenparsing/11326f4677f772a81392 to your computer and use it in GitHub Desktop.
Self Hosted Array Supporting Private State
class X {
constructor(len) {
let target = Object.create(new.target.prototype);
let handler = {
// handler stuff - special logic for "length" and integer properties
// Otherwise, use target's properties
};
return Reflect.construct(Proxy, [target, handler], new.target);
}
}
class Y extends X {
#foo;
constructor() {
super(10);
}
get foo() { return this.#foo }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment