I'm very new to JavaScript, please bear with me if this is quite obvious.
I was watching this video about the event queue and I wrote this code segment to try and see if I understood how JavaScript queues asynchronous functions into their section (I'm not sure what it's called. In the video, it called it a webapi).
setTimeout( () => console.log('hello'), 5000);
setTimeout( () => console.log('123'), 5000);
From my understanding, the first line of code gets sent off to a separate thread where it starts to get evaluated. Then, the second line of code gets sent off to another thread (different from the first) to get evaluated. As each of these evaluations complete in their own separate threads, they will eventually call their callback function, adding it to the task queue, where the event loop will push them back into the main stack.
I'm hoping someone can confirm or correct me on this, and would appreciate any further reading to help solidify this idea. I have to admit, when I first started reading about asynch functions, I was puzzled since I thought JavaScript was single threaded (so how could it yield any benefits?). I know, foolish.