Event model asynchrony in JavaScript

You know that using the addEventListener method, you can subscribe to various events that occur on page elements. For example, let's subscribe to a click on some element, the reference to which is stored in the variable elem:

javascriptelem.addEventListener('click', function() {
  console.log('1');
});

console.log('2');

In the above code, the second output to the console will be executed first. When will the first one be done? Once upon a time: execution of this code waits for an event to occur - a click on an element. As soon as this happens, our code will be executed.

Задание 1

Tell me in what order the numbers will be displayed in the console:

javascriptelem1.addEventListener('click', function() {
  console.log('1');
});
elem2.addEventListener('click', function() {
  console.log('2');
});