Skip to content

Instantly share code, notes, and snippets.

@iiison
Created July 31, 2021 03:27
Show Gist options
  • Save iiison/e14941c242645dd4f6e7c2e8aa8340f0 to your computer and use it in GitHub Desktop.
Save iiison/e14941c242645dd4f6e7c2e8aa8340f0 to your computer and use it in GitHub Desktop.
Watch object change
var obj = {
a : 'value',
b : 'another value'
}
var objProxy = new Proxy(obj, {
set(target, key, value) {
console.log({ key, value })
if (key === 'b') {
debugger
}
}
})
obj = objProxy
obj.a = 'test' // logs `a` as key and `test` as value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment