Very simple proxy using the set trap

suggest change

This proxy simply appends the string " went through proxy" to every string property set on the target object.

let object  = {};

let handler = {
    set(target, prop, value){ // Note that ES6 object syntax is used
        if('string' === typeof value){
            target[prop] = value + " went through proxy";
        }
    }
};

let proxied = new Proxy(object, handler);

proxied.example = "ExampleValue";

console.log(object); 
// logs: { example: "ExampleValue went trough proxy" }
// you could also access the object via proxied.target

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents