function getdata(id,callback){
console.log(id)
setTimeout(()=>{
if(callback){
callback();
}
},2000)
}
getdata(1,getdata(2));
I am not getting how getdata(2) is executing first here? As per my understanding it should print 1 first, i am confused why its sequence is diff and what if i write
getdata(1,()=>{getdata(2)}); how this makes correct 1 2 sequence