Javascript — Event loop

Have you ever seen the below code and wondering why people write something to wait for 0 sec?

setTimeout( () => {console.log('wait for 0 sec')},0)
  1. Call stack: Execution context. which is a place to keep track of the function
  1. Block by asynchronous function. when you run an async function you will need to wait till finish to move to the next step
  1. Event loop: come in to help squeeze your small tasks into your busy schedule
  1. Web APIs: setTimeout
  2. Eventloop: arrange when to run function1(), callback1(), callback2()
setTimeout( () =>{console.log('wait for 10 sec')},10)
  1. setTimeout’s time means the minimum wait till the execution

Hello, I am Heidi. I started this medium blog to post all of the note I have when I am learning new things. Hope you find it useful as well:)