for of loop javascript mdn code example
Example 1: forloop in js
for(i = 0; i < x; ++i){
}
Example 2: for of mdn
let iterable = new Uint8Array([0x00, 0xff]);
for (let value of iterable) {
console.log(value);
}
Example 3: for of mdn
function* fibonacci() {
let [prev, curr] = [0, 1];
while (true) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
for (let n of fibonacci()) {
console.log(n);
if (n >= 1000) {
break;
}
}
Example 4: use these instead of a for loop javascript
const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) {