Answers for "mdn for of loop"

12

javascript loop

let array = ['Item 1', 'Item 2', 'Item 3'];

// Here's 4 different ways
for (let index = 0; index < array.length; index++) {
  console.log(array[index]);
}

for (let index in array) {
  console.log(array[index]);
}

for (let value of array) {
  console.log(value); // Will each value in array
}

array.forEach((value, index) => {
  console.log(index); // Will log each index
  console.log(value); // Will log each value
});
Posted by: Guest on March-25-2020
15

javascript for loop

for (let count = 0; count < 90; count++) {
	// ...
}
Posted by: Guest on September-29-2020
2

use these instead of a for loop javascript

const array = [1, 2, 3];array.forEach(function(elem, index, array) {    array[index] = elem * 2;});console.log(array); // [2,4,6]
Posted by: Guest on January-25-2020
0

for of mdn

let iterable = new Map([["a", 1], ["b", 2], ["c", 3]]);

for (let entry of iterable) {
  console.log(entry);
}
// [a, 1]
// [b, 2]
// [c, 3]

for (let [key, value] of iterable) {
  console.log(value);
}
// 1
// 2
// 3
Posted by: Guest on September-29-2020
0

for of mdn

let iterable = new Uint8Array([0x00, 0xff]);

for (let value of iterable) {
  console.log(value);
}
// 0
// 255
Posted by: Guest on January-05-2021
0

for of mdn

let array = [10, 20, 30];

for (let valore of array) {
  console.log(valore);
}
// Output:
// 10
// 20
// 30
Posted by: Guest on January-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language