why console order is 2 3 1 ? each script seem to wait promise task,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script>
setTimeout(() => console.log(1), 0);
Promise.resolve(2).then(console.log);
</script>
<script>
console.log(3);
</script>
</head>
<body></body>
</html>
I thought it would be 3 2 1. but obviously I was wrong
why 2 output before 3, Promise then callback will exec in nexttick,and console.log(3); is sync task.