Iterables and Generators
For Of Iterables
for...of reads values from arrays, strings, maps, sets, and other iterable objects.
For Of Iterables
forof.ts
const count: number = ;
const values: number[] = [1, 2, 3, 4];
let total: number = 0;
for (const value of values.slice(0, count)) {
total = total + value;
console.log(`step=${total}`);
}
console.log(`total=${total}`);
const count: number = ;
const values: number[] = [1, 2, 3, 4];
let total: number = 0;
for (const value of values.slice(0, count)) {
total = total + value;
console.log(`step=${total}`);
}
console.log(`total=${total}`);
const count: number = ;
const values: number[] = [1, 2, 3, 4];
let total: number = 0;
for (const value of values.slice(0, count)) {
total = total + value;
console.log(`step=${total}`);
}
console.log(`total=${total}`);
for of
`for...of` asks an iterable for each next value and runs the loop body once per value.