Can someone please tell me program flow of this JavaScript code

  addeventlistener, html, javascript

HTML code

<button id="leave-button">Leave Room</button>

Client side code

const $leaveRoom = document.querySelector('#leave-button');
let a = 1;
$leaveRoom.addEventListener('click', () => {
    console.log(a);
    console.log("check");
    a++;
    $leaveRoom.click();
    console.log(a);
    a++;
});
The Output was:
1
check
2
check
3
4

This question may sound dumb but I am new to JavaScript. I am not able to understand the program flow of this code.

Source: Ask Javascript Questions

LEAVE A COMMENT