Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.