How do I constantly check a variables value. For example:
if(variable == \'value\'){
dosomething();
}
This would work if I constantly loope
This solution use deprecated APIs. Computed properties and proxies are a better alternative except on the oldest browsers. See K2Span's answer for an example of how to use those.
Object.watch:
Watches for a property to be assigned a value and runs a function when that occurs.
Object.watch() for all browsers? talks about cross-browser ways to do Object.watch
on browsers that don't support it natively.