[Javascript] Wrap Arrays with Proxy
In contrast to other built-ins, Arrays can be wrapped transparently:
const p = new Proxy(new Array(), {}); p.push('a'); assert.equal(p.length, 1); p.length = 0; assert.equal(p.length, 0);
The reason for Arrays being wrappable is that, even though property access is customized to make .length
work, Array methods don’t rely on internal slots – they are generic.