Let's say I have a variable
let foo = {};
And I'm re-assigning it to something else.
foo = {}
The question is how do I know that the variable is re-assigned ?
Like I've heard about Proxy, but it doesn't work
// Creating a variable
let foo = {}
// Setting up a proxy
const fooProxy = new Proxy(foo, _ => {
get: function(...) { ... },
set: function(...) { ... }
}
// I just re-assigned the variable, and I want that `notify()` to tell me about it.
foo = {}
// I wanna call this function when the variable changes, but it doesn't work
function notify(){
console.log("Dude, your variable has changed!");