How do I constantly check a variables value. For example:
if(variable == \'value\'){
    dosomething();
}
This would work if I constantly loope
Object.defineProperty(Object.prototype, 'watch', {
    value: function(prop, handler){
        var setter = function(val){
            return val = handler.call(this, val);
        };
        Object.defineProperty(this, prop, {
            set: setter
        });
    }
});
How to use:
var obj = {};
obj.watch('prop', function(value){
    console.log('wow!',value);
});
obj.prop = 3;