I'm using Nodejs, and I'm confused about the asynchronous characteristics of JavaScript.
If there are no callback functions or promises, is every function executed in asynchronous way?
For example,
let arr = []
for (let i = 0; i < 600; i++) {
    arr.push(i)
}
console.log(arr)
arr = []
console.log(arr)What if arr becomes an empty array while arr is being pushed by the 'for' statement?
I executed above code several times, and fortunately, there were no worring situation. Is that a coincidence?
Here is another example:
function foo(num) {
    console.log(num)
}
let a = 0
foo(a)
a = 1I want to make foo(a) in the above code always returns 0, not 1.
What if Node.js runtime executes a=1 earlier than foo(a)?
Should I add promise in these trivial cases?
 
     
    