I am learning JavaScript and I added some JavaScript code on Chrome Dev Tools or JavaScript Console to delay or block clicking any button on a website in a number of seconds. And it worked as expected. However, that click triggered automatically after a couple of seconds. Why might that be? Does JavaScript have a queue of event listeners that constantly checked if there are any of them and act on those events?
function hang(secs) {
const doneAt = Date.now() + (secs * 1000)
while (Date.now() < doneAt) {}
}
hang(10)