-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbol.js
42 lines (35 loc) · 857 Bytes
/
symbol.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
const ford = {
sellLeader: 'F150',
sellLeaderPrice: '39k USD',
[Symbol.iterator]: function* () {
yield this.sellLeader;
yield this.sellLeaderPrice;
}
};
const chevy = {
sellLeader: 'Silverado',
sellLeaderPrice: '38.900k USD',
[Symbol.iterator]: function* () {
yield this.sellLeader;
yield this.sellLeaderPrice;
}
};
const car = {
ford,
chevy,
nrBrands: 2,
avgPrice: '35k USD',
marketLeader: 'Ford',
[Symbol.iterator]: function* () {
yield `Nr Brand Leaders ${this.nrBrands}`;
yield `Avg Price: ${this.avgPrice}`;
yield* this.ford;
yield* this.chevy;
yield `Leader 2016: ${this.marketLeader}`;
}
};
const weirdExample = [];
for (let item of car) {
weirdExample.push(item);
}
console.log(weirdExample);