Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created Jan 10, 2018
Embed
What would you like to do?
const obj = {};
const p = new Proxy(obj, {
get: (target, name) => {
console.log(`(get) target : ${JSON.stringify(target)}, name: ${name}`);
return target[name];
},
set: (target, name, value) => {
console.log(`(set) target : ${JSON.stringify(target)}, name: ${name}`);
target[name] = value;
}
});
p.a = "hello";
p.a
// -> hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment