var a=0;
var timer=setTimeout(function(){
a++;
},1000);
if(a>0){
alert("1");
}
I clearly changed the value of a in this code in the timer, why is the output still 0?
How should I write to make this pop-up window pop up? (Based on making the judgment effective. )
伊谢尔伦2017-05-19 10:36:41
The execution sequence you imagined
var a = 0;
a++;
console.log(a);
Actual execution sequence
var a = 0;
console.log(a);
delay 1 second ……
a++;
There are many ways to get this a=1, but you don’t know the meaning here, what is it for.
If you have additional questions, please put them in the question, not in the comments of the question.