Here, it gives me the output of 0, 1, 2 just like the for loop except it only logs one number at a time.
I'm new to jQuery and I just stumbled across this line of code here. Can anyone explain the mechanic behind the working of this code? The thing that left me baffled is the third line of code.
var i = 0;
setInterval(() => {
i = (i + 1) % 3;
console.log(i);
}, 1000);