Is it possible (using jQuery or otherwise) to listen for a change in the value of a non-DOM Javascript object (or variable)?
So, for instance, I have:
function MyObject(){
this.myVar = 0;
}
var myObject = new MyObject();
myObject.myVar = 100;
Is there a way to listen for when the value of myVar changes and call a function?
I know that I could use getter/setters, but they aren’t supported in previous versions of IE.
If IE is important, I guess you are not interested in Watch
But someone seems to have written a shim which makes this question a duplicate
Watch for object properties changes in JavaScript