Created
July 31, 2021 03:27
-
-
Save iiison/e14941c242645dd4f6e7c2e8aa8340f0 to your computer and use it in GitHub Desktop.
Watch object change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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