Javascript Proxies are a new addition in ES6. It’s a powerful feature that can be used for solving various problems elegantly. We are going to examine and re-create a small utility library by Sindre Sorhus called on-change. The aim is to conceptually understand JavaScript Proxies, and in the process, build something so that the concepts are reinforced.
JavaScript’s dynamic nature, first-class functions and prototypes could always be used for elegant metaprogramming. Proxies let programmers further blur the line between the native, user defined objects and the host objects.
One of the new features introduced in the ES6 standard is the Proxy object. The Proxy object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment…