// A simple Javascript Object / String var object = "hello"; // Imagine a button in the DOM, and if it clicked the object value will change document.getElementById("button").onclick = function(){ window.object = "hello world"; } // Now I would like to track and do something when the object is changed, ex: object.onreadystatechange = function(){ alert(object); }
Note. This may seem silly because I can get the change in the onclick event on the button, but this is not what I want, I want to strictly track the change in the object itself for any kind of use, the above code is just an example.
Adam source share