I have this code here:
var foo = 0;
setInterval(function(){foo++}, 1000);
This will increase foo
by 1 every second. Is there any way to define a bar
variable which will be the foo
variable at that time and not changing?
It sounds confusing, so here:
For example:
var foo = 0;
setInterval(function(){foo++}, 1000);
setTimeout(function(){var bar = foo}, 4000) //bar = 4;
Is there anyway to keep bar
at 4 and not increasing with foo
? Thanks a lot!
(Sorry for bad English)