I want to pass a global parameter to a function in a setTimeout
, but I want the value to stay at when the setTimeout
is interpreted:
var a=0;
setTimeout(function(){
console.log(a);
},5000,a)
a=1;
//output is 1 and should be 0
How can I fix this? I already searched Stack Overflow for an answer but didn't find anything.