Perhaps I’m missing something major, but is there a way to use Object.watch() on variables that exist independent of objects?
I’m a bit new to JS, and couldn’t find any kind of global object that my variable was attached to.
(Also, just using this for debugging, so the fact that it’s only supported in Mozilla browsers isn’t a problem.)
The global scope in a browser is actually the
windowobject, so if your variable is a global variable, it’s actually attached to thewindowobject. So you can access it aswindow.variableNamejust as well as simplyvariableName. And thus you should be able to say: