When working with JavaScript ES6 Proxies, the set property trap for array.length does not fire when assigning array indexes directly.
For example:
const proxy = new Proxy([], {
set: function(obj, name, value) {
console.log(`set: ${name}`);
obj[name] = value;
return true;
}
});
proxy.push(0);
proxy[1] = 1;
Chrome 51 and Firefox 47 outputs:
set: 0 set: length set: 1
While I would expect:
set: 0 set: length set: 1 set: length
Is this per spec? I couldn't find any information on this.