after this code is executed, the console outputs 0 directly without first executing the anonymous function
in setInterval (). The code is as follows:
var div = document.getElementById("div");
div.onclick = function() {
var i = 0;
var timer = null;
timer = setInterval(function() {
iPP;
console.log(i)
if(i == 10) {
clearInterval(timer);
}
},300);
if(i == 0) {
clearInterval(timer);
console.log(i);
}
}
is inexplicable! Ask the great god to solve the doubt