bhylu.com

Advertisements

Meta Reference

Reflect and Proxy solve different parts of the same problem. Reflect performs operations; Proxy can intercept them.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const target = {places: 12};
const wrapped = new Proxy(target, {has: (object, key) => Reflect.has(object, key)});
console.log("places" in wrapped);

What happens

The has trap confirms the property exists.