2.5 Event loop
單線程(single threaded)
堆疊(stack)
function b() {
}
function a() {
b()
}
a()JavaScript如何執行非同步事件(asynchronous callback)

Last updated
function b() {
}
function a() {
b()
}
a()
Last updated
/*Copy from JavaScript: Understanding the weird part*/
function waitThreeSeconds(){
var ms = 3000 + new Date().getTime();
while(new Date() < ms){}
console.log("finished function");
}
function clickHandler(){
console.log("click event!");
}
document.addEventListener('click', clickHandler);
console.log("started execution");
waitThreeSeconds();
console.log("finished execution");