Proxies and Generators in JavaScript

By Jordan Irabor

Let’s take a dive at two constructs that were introduced in the JavaScript ES6 specification:

  1. Proxy
  2. Generator

A solid understanding of these constructs will prove handy when working with JavaScript at a relatively low level. In this article, we will go over certain use cases where these constructs fit right in and will definitely save you several keystrokes.

Proxies

A Proxy, in simple terms, is an object that controls access to another object. According to the MDN docs:

The Proxy object is used to define custom behaviour for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).

This description roughly translates into the idea that we can intercept fundamental operations (e.g function invocation, property lookup, assignment, enumeration, etc) on ob

Source:: scotch.io