Last active
September 17, 2015 16:14
-
-
Save zenparsing/11326f4677f772a81392 to your computer and use it in GitHub Desktop.
Self Hosted Array Supporting Private State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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