Skip to content

Commit 7107356

Browse files
committed
Another Example of set time out in JS
1 parent e7cdce7 commit 7107356

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

settm.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//using var and closure set timeout
2+
function f()
3+
{
4+
console.log("Hello JS !");
5+
for (var i=1; i<=5; i++)
6+
{
7+
function closer(a)
8+
{
9+
setTimeout(function()
10+
{
11+
console.log(a);
12+
}, a*1000);
13+
}
14+
closer(i);
15+
}
16+
}
17+
f();
18+
19+
20+
21+
22+
23+
24+
/*function F()
25+
{
26+
console.log("Hello JavaScript !");
27+
for (let i=1;i<=5;i++)
28+
{
29+
setTimeout(function()
30+
{
31+
console.log(i);
32+
}, i*1000);
33+
}
34+
}
35+
F();*/

0 commit comments

Comments
 (0)