Why alert (); run before console.log ();

How is my question different from others?

I am using ES6 syntax. Other issues that I have been considering use ES5 syntax.

Question

Why alert();does it work before console.log();? And can I make it console.log();execute before alert();?

My code

console.log("Hello!");
alert("Hi!");
+4
source share
1 answer
console.log("Hello!");
setTimeout(() => alert("Hi!"), 0);

: console.log() . . , , alert() , : " , ". console.log , .

- 0- setTimeout - , JavaScript: ", , ".


† , - console.log(new Date().toString()); , , . , , , .

+3

Source: https://habr.com/ru/post/1688771/


All Articles