function func1(){ setTimeout(()=>{ console.log(x); console.log(y); },3000); var x = 2; let y = 12; } code example
Example: for (var i = 0; i < 10; i++) { setTimeout(function () { console.log(i) }, 10) } What
for (var i = 0; i < 10; i++) {
setTimeout(
(function (i) {
console.log(i)
})(i),
10
)
}