“Loop Array JavaScript” Code-Antworten

JavaScript Loop Array

function delay(time) {
  return new Promise(resolve => setTimeout(resolve, time));
}

delay(1000).then(() => console.log('ran after 1 second1 passed'));
Powerful Puma

JS Loop Array

var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Grepper

Loop Array JavaScript

var colors = ['red', 'green', 'blue'];
	
	colors.forEach((color, colorIndex) => {
     console.log(colorIndex + ". " + color); 
    });
Magnificent Moth

Array Loop JS

var arr = ["f", "o", "o", "b", "a", "r"]; 
for(var i in arr){
	console.log(arr[i]);
}
FlashingMustard

JavaScript -Schleife durch Array

var colors = ["red","blue","green"];
colors.forEach(function(color) {
  console.log(color);
});
Gifted Gerenuk

Loop -Array in JavaScript

function in_array(needle, haystack){
    var found = 0;
    for (var i=0, len=haystack.length;i<len;i++) {
        if (haystack[i] == needle) return i;
            found++;
    }
    return -1;
}
if(in_array("118",array)!= -1){
//is in array
}
simon s

Ähnliche Antworten wie “Loop Array JavaScript”

Fragen ähnlich wie “Loop Array JavaScript”

Weitere verwandte Antworten zu “Loop Array JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen