I have a confusion regarding after the settimeout finishes what does it put in the callback queue does it put the function name/function defination(that we pass as parameter to the settimeout) or the function invoked
function cb(){
console.log("Hi!")
}
setTimeout(cb,2000) // what will be put on the callback queue after 2 sec cb or cb()
so now if i call setTimeout(cb,2000)
after that what will it put in the call back queue just cb or cb()
and if i assume it puts just cb like that and when the eventloop puts the cb in the call stack it will execute the cb function So if thats the case then if i have:
function cb(num){
console.log(num);
console.log("Hi!")
}
and call setTimeout(cb,2000,5)
so for that case after the timer is done and if it puts only cb in the callback queue then when the event loop puts the cb into the call stack how does it remember or pass it the num parameter(the value 5 in this case) as it logs 5 to the console.
Any help is greatly appreciated as i am not able to set a mental model for this confusion.