Ask coding questions

← Back to all posts
Help me please
h
AlmightyDeaks (5)

whenever i run the reple it crashes

Answered by notGilbert (121) [earned 5 cycles]
View Answer
Comments
hotnewtop
notGilbert (121)

Javascript is a single-threaded language, which means infinite while loops will freeze the page.

If you want to repeat forever use setInterval or requestAnimationFrame:

function forever() {
  console.log('loop non blocking')
  requestAnimationFrame(forever);
}

forever();

read this short article