There are situations where we need "stable references" to objects. Example createRef โ React
That function creates special Reference object that later will receive real object. The caveat is that we always need to access real value with .current property
In fact that functionality may not require anything special. That createRef can be implemented as
function createRef() {
let p;
function apply(that) { Proxy.changeTarget(p,that) }
p = new Proxy(null, {apply});
return p;
}
So we can use proxies also as object references.
function Component() {
const input = createRef();
return <main>
<label>ref</label>
<input type="text" ref={input} />
<button onClick={ () => input.focus() }>focus</button>
</main>
}
here input will receive reference to real DOM element after its creation.