Thank you for reading this. So I stumbled upon some unexpected behaviour. I thought the code beneath would execute the callback functions in the settimeout function the 1 second passed.
setTimeout(() => {console.log("this is the third message")}, 1000);
setTimeout(() => {console.log("this is the third message")}, 1000);
setTimeout(() => {console.log("this is the third message")}, 1000);
var a = [1,2,3,4,5,6,7,8,9]
var counter = 0
while (a.length > 3){
if (counter == 30000){
break
}
console.log(a)
counter ++
}
After the while loop is done, the callback functions get executed, I think it's really weird behaviour. Also, imagine if I'd put a setTimeout statement in a function and that function executes, would the timer then start counting down when the function is called, directly, or only when the line it's located at is being read? If there is any good, extensive articles or documentation that really go deep into it, I'd really appreciate that!