loading
main.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
// Data definition
let primeNumbers = [2,3,5,7,11];
let jsFramework =  new Map([['name','React'],['creator','Facebook'],['purpose','UIs']])

// Option 1 ES6 for..of on array which is iterable
let loopStartOpt1 = performance.now();

for (let value of primeNumbers) {
    console.log(value);
}
console.log(performance.now() - loopStartOpt1 + ' ms')

// Option 2 ES6 for..of on Map which is iterable
let loopStartOpt2 = performance.now();
for (let [key, value] of jsFramework){
    console.log(key+' : '+ value);
}
console.log(performance.now() - loopStartOpt2 + ' ms')

// Manually progress over iterable with next()
// Create array from Map keys 
let characteristics = jsFramework.keys();
console.log(characteristics.next().value);
console.log(characteristics.next().value);
console.log(characteristics.next().value);
// Output return value of next() confirming iterable reached end
console.log(characteristics.next());
Native Browser JavaScript