How do I constantly check a variables value. For example:
if(variable == \'value\'){
dosomething();
}
This would work if I constantly loope
As @Pekka commented, you can have a timer constantly poll the variable. A better solution, if it's all your code that's changing the variable, is to not just set the variable directly, but rather have all setters call a function. The function could then set the variable and do any additional processing you need.
function setValue(value) {
myVariable = value;
notifyWatchers();
}