Horje
for of js Code Example
for of js
//for ... of statement

const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}

// expected output: "a"
// expected output: "b"
// expected output: "c"
for of loop javascript
const people = [{ name: 'Karl', location: 'UK' }, 
                { name: 'Steve', location: 'US' }];

for (const person of people) {
    console.log(person.name); // "karl", then "steve"
    console.log(person.location); // "UK", then "US"
}
javascript for of
const array = ['hello', 'world', 'of', 'Corona'];

for (const item of array) {
  console.log(item);
}
for...of...loop
const array = ['a', 'b', 'c', 'd'];
for (const item of array) {
	console.log(item)
}
// Result: a, b, c, d

const string = 'Ire Aderinokun';
for (const character of string) {
	console.log(character)
}
// Result: I, r, e, , A, d, e, r, i, n, o, k, u, n
Source: bitsofco.de
for..of
let colors = ['Red', 'Green', 'Blue'];

for (const [index, color] of colors.entries()) {
    console.log(`${color} is at index ${index}`);
}Code language: JavaScript (javascript)
for of js
for (variable of iterable) {
  statement
}




Javascript

Related
JavaScript querySelector - By ID Code Example JavaScript querySelector - By ID Code Example
get value in maps loop using enzym Code Example get value in maps loop using enzym Code Example
javascript short syntax get element Code Example javascript short syntax get element Code Example
coreui react change background color Code Example coreui react change background color Code Example
nth value of the Fibonacci sequence in js Code Example nth value of the Fibonacci sequence in js Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11