Jim: Unlike in C/C++, JS's main function are not supposed to be run in an (more or less) infinite loop. The browsers has other things to do, like handling I/O, rendering, ...
Therefore JS's "main", must be run a regular intervals using either setTimeout( functionHandle, delayInMs ) which will jump to the functionHandle once, or setInterval( functionHandle, delayInMs ) which will (do its best to) jump functionHandle every delayInMs ms.
Notice that to avoid consuming all the CPU resources, browser vendors allocate some time slots to the JS engine. Therefore if it's very small the delayInMs will not matter. The browser will execute the code at the next time slot. In practice 20ms is safe.
But within this 20ms, you nothing forbids you to compute several things.