-
Notifications
You must be signed in to change notification settings - Fork 0
/
scope.ts
50 lines (45 loc) · 798 Bytes
/
scope.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
for (var i = 0; i < 10; i++) {
setTimeout(() => {
console.log(i);
}, 1000);
}
// for (let i = 0; i < 10; i++) {
// setTimeout(() => {
// console.log(i);
// }, 1000);
// }
// for (var i = 0; i < 10; i++) {
// (function (i) {
// setTimeout(() => {
// console.log(i);
// }, 1000);
// })(i);
// }
// for (var i = 0; i < 10; i++) {
// setTimeout(
// function (i) {
// console.log(i);
// },
// 1000,
// i
// );
// }
// //
// for (var i = 0; i < 10; i++) {
// let j = i;
// setTimeout(() => {
// console.log(j);
// }, 1000);
// }
function* generator(i) {
while (true) {
yield i++;
}
}
const gen = generator(0);
for (var i = 0; i < 10; i++) {
// setTimeout(() => {
console.log(gen.next().value);
// }, 100 * i);
}