Javascript setInterval works but not infinite loop

前端 未结 2 1309
情歌与酒
情歌与酒 2021-01-25 08:41

I don\'t understand why the infinite loop does not work but uncommenting the function call works.




        
2条回答
  •  不要未来只要你来
    2021-01-25 09:05

    When you use setInterval you keep adding the function you are calling to the queue of things for the browser to do. Repaint events are also added to this queue.

    When you use an infinite loop, the browser never gets to the end of the function, so it never gets around to running a repaint and the image in the document never updates.

提交回复
热议问题