METAPROGRAMMING IN JAVASCRIPT

Introduction to “Proxy” API for Metaprogramming in JavaScript

In this lesson, we are going to learn about the `Proxy` class available in the ES2015+. It provides a mechanism to intercept basic JavaScript operations on objects.

Uday Hiwarale
JsPoint
Published in
8 min readAug 16, 2020

--

(source: unsplash.com)

In the earlier lesson, we learned about some metaprogramming concepts one of which is intercession. Intercession stands for intervening in an operation or intercepting an operation. For example, if you trying to get the value of an object’s property, but that operation was intercepted by some JavaScript program and a false or modified value was returned instead.

Intercession is like a man-in-the-middle attack where data is transformed in-flight between the source and the consumer but done deliberately. The program that sits between the source and the consumer is called Proxy.

You may have heard about this term while connecting to a remote server through a proxy server that sits between you and the remote server. Here the proxy server is able to hide your identity from the remote server as well as transform data received from the remote server if necessary.

--

--