console.log("(t23 code demo by var,let,const feature use node.js !) ")
var messages = ["showout=>1", "showout =>2", "showout=>3"];
const cnt = 10;
for (var i = 0; i < messages.length; i++) {
setTimeout(function() {
console.log("[loop1]:" + messages[i]);
console.log("[loop1]:" + "t=", t, "j=", j, "cnt=", cnt);
}, i * 1500);
}
var j = 10;
let t = 10;
for (let i = 0; i < messages.length; i++) {
setTimeout(function() {
console.log("[loop2]:" + messages[i], i);
console.log("[loop2]:" + "t=", t, "j=", j, "cnt=", cnt);
}, i * 1500);
t += 1;
j += 1;
}
{
var jj = 10;
let tt = 10;
for (let i = 0; i < messages.length; i++) {
setTimeout(function() {
console.log("[loop3]:" + messages[i], i);
console.log("[loop3]:" + "tt=", tt, "jj=", jj, "cnt=", cnt);
}, i * 1500);
tt += 1;
jj += 1;
}
}