JSFiddle - React, Tailwind, and code Playground
JavaScript
const impl = Symbol("impl")
class Foo {
get bar() {
return this[impl].bar;
}
}
class FooImpl {
constructor(bar) {
this.bar = bar;
}
get(target, prop, receiver) {
return prop == impl ? this : Reflect.get(...arguments);
}
}
const foo_impl = new FooImpl(42);
const foo = new Proxy(new Foo(), foo_impl);
const foo_broken = new Proxy(foo, {get: function(target, prop, receiver) { return prop != "bar" ? undefined : Reflect.get(...arguments); }});
console.log(foo_broken.bar);