Intercepting sets on array-like objects

Allen Wirfs-Brock allen at
Thu Jun 8 22:59:11 UTC 2017

> On Jun 8, 2017, at 11:32 AM, Tab Atkins Jr. <jackalmage at> wrote:
> Naively, this requires a Proxy, so we can intercept uses of the []
> syntax.  However, we don't need all the rest of the Proxy
> functionality, just this one intercept - a setter function, just for
> `obj[foo]` rather than ``.  Further, Typed Arrays already have
> *precisely* the functionality I'd like to use - they intercept setting
> using [], and convert it into the appropriate type of number.  AWB
> also proposed adding exactly this hook in the past (I think it was
> called "Array reformation" or something?).

that proposal page can be access here: <> 

the basic idea was that distinct internal methods (Proxy traps) are used for . and [] property accesses and that the default behavior for [ ] accesses is to look for specific symbol-keyed methods and if found defer the access logic to the method.  If not found the behavior is the same as for . accesses.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list