In Javascript, most functions get called one at a time, or synchronously. Execution happens in order, one a time. Standard functions like Math.random
, Math.floor
are synchronous functions. They get executed immediately, and to the exclusion of any other runtime operation. This is the default behavior of javascript, and so obvious we barely even think about it.
const x = Math.random();
console.log(x) // 0.6142...
Synchronousity is about dependency; Line 2 waits for Line 1 because Line 2 is dependent on line 1. This code is said to have a synchronous flow. Because theses line depend on one another, the user waits until Math.random() has returned a value. This happens so fast that it doesn't hurt UX, but it does take some minuscule amount of time.