I was coding recently and was stuck scratching my head over why, even when I pass the string that is initialised already, as a parameter, the setTimeout’s callback function still prints it as undefined.
Does it not keep track of the variable it needs later?
This is the simple illustration:
console.log("lets start");
const str="123";
setTimeout((str)=>console.log(str),5000);
so should i never pass an argument in setTimeout?
3