Meta Proxy
A Proxy can intercept operations on a target object. Forward operations deliberately so normal behaviour stays understandable.
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
const session = new Proxy({places: 12}, {
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
}
});
console.log(session.places);
What happens
The get trap forwards the read and returns 12.