“por” Código de respuesta

Cómo usar en JavaScript

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

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

use estos en lugar de un javaScript para bucle

const array = [1, 2, 3];array.forEach(function(elem, index, array) {    array[index] = elem * 2;});console.log(array); // [2,4,6]
Brainy Butterfly

por

const iterable = new Set([1, 1, 2, 2, 3, 3]);

for (const value of iterable) {
  console.log(value);
}
// 1
// 2
// 3
Tender Tamarin

para de js

for (variable of iterable) {
  statement
}
Homely Heroin

use estos en lugar de un javaScript para bucle

const array = [1,2,3,4,5];const evenNumbers = array.filter(function(elem) {   // expressions that return 'true' are retained   return elem % 2 == 0;});
Brainy Butterfly

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código