var variable = 1;
var prev;
function check(value) {
var f = value == prev;
prev = value;
return f;
}
setInterval(function() {
variable = Math.random() > 0.5 ? 1 : 0;
}, 2500);
setInterval(function() {
console.log(prev, variable, prev == variable)
console.log('check', check(variable))
}, 5000);