請問一下各位大大
<!DOCTYPE html>
<html>
<body>
<p> line 1 </p>
<p id="demo"></p>
<p> line 2 </p>
<script>
var cars = ["BMW", "Volvo", "Saab", "Ford"];
var i = 0;
var text = "";
while (cars[i]) {
text += cars[i] + "<br>";
i++;
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
line 1
BMW
Volvo
Saab
Ford
line 2
我知道 getElementById是抓取ID的屬性的物件
可是<p id="demo"></p>並非函數 也沒呼叫 為何會跳去先執行
document.getElementById("demo").innerHTML = text; 而非按照順序由上往下執行呢?