let i = 0
function pollDOM() {
console.log(i)
i++
setTimeout(pollDOM, 3000) // try again in 300 milliseconds
}
pollDOM()
The above function use to run every 3 second, output is like:
1
// wait 3 seconds
2
// wait 3 seconds
3
// wait 3 seconds
4
// wait 3 seconds, and so on...
But in Next.js, it produces a result as:
1
2
// wait for 3 seconds
3
4
// wait for 3 seconds
5
6
// wait for 3 seconds, and so on...
Why it is produced this way, two numbers together?
How can I achieve that that I am achieving in normal JavaScript?