If you create a closure for it, you don’t have to pass the value at all, it will be available only in the inner area, but not outside the function Test:
function Test() {
var value = 50;
var intervalID = setInterval(function() {
if(value > 100)
clearInterval(intervalID);
value += 10;
}, 1000);
}
Test();
source
share