do
function loop(){
if (/*value*/ != old){ //check if the value is not old
//do stuff
}
old = /*value*/ //set old to value
requestAnimationFrame(loop) //loop every frame
}
requestAnimationFrame(loop) //wait a frame
or
function changed(){
var change = /*value*/ != old //check if the value is not old
old = /*value*/ //set old to value
return change //output change
}
and replace /*value*/ with the value to check 🙂