I have a piece of code as this :
function imp(user) {
return console.log("user", user)
}
var msg = imp("Jenny")
console.log("msg", msg)
I'm getting an output as this :
user //for user log
undefined // for msg log
However I expect this undefined if the code was async, for example a setTimeout call inside the imp function as :
function imp(user) {
setTimeout(() => {
console.log("inside the timeout for ", user)
}, 3000)
}
But since the very top code is sync, then still why it logs undefined ?
Isn't that equal to simply assigning a new variable (msg) to a function call?
Thanks for reading