1) function a(b){
b()
}
a(()=>{
console.log('a')
})
2) function b(c){
setTimeout(()=>{
c()
},0)
b(()=>{
console.log('b')
})
Just tell me if all execution happening in example 2 similar to example 1
In example 2 what is happening which i explain here.
When function b is involved, it will be pushed into call stack
After that setTimeout function will be involved . As it has a timer, it is moved into Web API . It will be waited till 0 milliseconds. Then call back will be moved into event queue. In event queue call back will be compute it’s execution. Once call stack is empty, event loop placed this call back to call stack for execution. This is what happening in example 2 according to my knowledge.
But in example one there is no setTimeout function. so my doubt is that as there is no setTimeout function declared in example 1, will the call back in function a moved to event queue or call back queue
Is call back queue and event queue same