Re:Proxy, a new JavaScript ES6 feature
by foob on Friday May 18, 2018 @07:58AM
(#17100684)
One possibility is adding syntactic sugar to objects. I posted elsewhere in this thread about how we used them in Remote Browser, but here's a simple example of adding support for negative indexing to an array. This basically creates a shorthand for array[-n] === array[array.length - n].
You could accomplish the same thing by creating explicit setters and getters, but proxies allow you to directly intercept and modify the behavior of property access, calling an object like a function, etc. This sort of flexibility allows you to create APIs that wouldn't be possible otherwise.
[ Parent
| on HN ]
There are no comments on this comment yet.