Skip to content

Instantly share code, notes, and snippets.

@HasanHuseyinDemir
Last active September 12, 2023 19:18
Show Gist options
  • Save HasanHuseyinDemir/3e17d805a59f71170c81cb5887be58c5 to your computer and use it in GitHub Desktop.
Save HasanHuseyinDemir/3e17d805a59f71170c81cb5887be58c5 to your computer and use it in GitHub Desktop.
Proxy Returner
function createProxy(obj) {
return new Proxy(obj, {
get(target, key) {
//Callback
return target[key];
},
set(target, key, value) {
//Callback
target[key] = value;
return true
}
});
}
/*
Example:
const values=createProxy({
x:0,
y:1,
z:2
})
values.x=1 //Callback triggered
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment