{ let i = 1; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { let i = 2; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { let i = 3; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { let i = 4; function timeoutHandler() { console.log(i); }; setTimeout(timeoutHandler, i * 1000); } { let i = 5; function timeoutHandler() { console.log(i); }; setTimeout(timeoutHandler, i * 1000); }
{ var i = 1; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { var i = 2; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { var i = 3; function timeoutHandler() { console.log(i); } setTimeout(timeoutHandler, i * 1000); } { var i = 4; function timeoutHandler() { console.log(i); }; setTimeout(timeoutHandler, i * 1000); } { var i = 5; function timeoutHandler() { console.log(i); }; setTimeout(timeoutHandler, i * 1000); i += 1; }
{ var i = 1; function helper(i) { function timeoutHandler() { console.log(i) } return timeoutHandler; } setTimeout(helper(i), i * 1000); } { var i = 2; function helper(i) { function timeoutHandler() { console.log(i) } return timeoutHandler; } setTimeout(helper(i), i * 1000); } { var i = 3; function helper(i) { function timeoutHandler() { console.log(i) } return timeoutHandler; } setTimeout(helper(i), i * 1000); } { var i = 4; function helper(i) { function timeoutHandler() { console.log(i) } return timeoutHandler; } setTimeout(helper(i), i * 1000); } { var i = 5; function helper(i) { function timeoutHandler() { console.log(i) } return timeoutHandler; } setTimeout(helper(i), i * 1000); i += 1; }