I was doing my tic-tac-toe project when I stumbled upon
setTimeOut to delay the alerts. I decided to ask for some help in stack overflow and learned a lot from the answer.
window.requestAnimationFrame() is used if you want to manually tell the browser to update the UI before the next repaint. This method takes a callback function which is invoked before the repaint. More information can be found in its comprehensive MDN docs.
This is my first time hearing about this
window.requestAnimationFrame function ever since I started learning js, around two years ago. Thank you to that SO user for the very insightful answer :).