forked from mechaniac/Map-of-Javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generator.js
91 lines (61 loc) · 1.18 KB
/
generator.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function* myGenerator(){
l('a')
yield 12;
l('b')
yield 22;
}
let g = myGenerator()
//l(g)
// l( g.next())
// l( g.next())
// l( g.next())
let g2 = myGenerator()
// for(const x of g2){
// x.value;
// }
function objectify(key, value){
let o = {}
o[key] = value
return o
}
function objectify2(key,value){
return{
[key]: value
}
}
let myO = objectify2('name', 'theC')
//l(myO)
const o = {
oi:{
a:['a1'],
b:['b1','b2'],
c:['c1','c2','c3'],
},
[Symbol.iterator]() {
const ra = Object.values(this.oi);
let ia = 0;
let i = 0;
return {
next() {
if(i>=ra[ia].length) {
ia++
i = 0
}
if(ia<ra.length){
return {value: ra[ia][i++], done: false}
}
return {value: undefined, done: true}
}
}
}
}
for(const x of o){
l(x)
}
l(...o)
let m = new Map([[1, 'a'],[2, 'b'],[3, 'c']])
l(m)
let a = new Array('a','b','c')
l(a)
var xy = 0;
l(xy++)