I'm trying to understand which parts of javascript are synchronous and which are asynchronous.

My question is, in the following code why does it alert `16384` *before* it alerts `1` when the loop takes waay longer than 1ms ?

**[Demo](http://jsfiddle.net/7X7F7/)**

```
setTimeout(function () {
    alert(1)
}, 1)

for (i = 0; i < 16384; i++) {
    for (j = 0; j < 16384; j++) {}
}

alert(j)

```