Javascript Loop Array
const array = ["one", "two", "three"] array.forEach(function (item, index) { console.log(item, index); });
Source: stackoverflow.com
javascript loop array
setTimeout(myFunction, 3000); // if you have defined a function named myFunction // it will run after 3 seconds (3000 milliseconds)
Source: stackoverflow.com
Javascript loop array
/** * Delay for a number of milliseconds */ function sleep(delay) { var start = new Date().getTime(); while (new Date().getTime() < start + delay); }
javascript loop array
array.forEach(el => { console.log(el); })
javascript loop array
var arr = [1, 2, 3, 4, 5]; for (var i = arr.length - 1; i >= 0; i--) { console.log(arr[i]); }
Source: www.techiedelight.com
javascript loop array
var arr = [1, 2, 3, 4, 5]; arr.slice().reverse() .forEach(function(item) { console.log(item); });
Source: www.techiedelight.com
javascript loop array
var arr = ['a', 'b', 'c']; arr.forEach(item => { console.log(item); });
Source: codeit.codes
javascript loop array
/* new options with IE6: loop through array of objects */ const people = [ {id: 100, name: 'Vikash'}, {id: 101, name: 'Sugam'}, {id: 102, name: 'Ashish'} ]; // using for of for (let persone of people) { console.log(persone.id + ': ' + persone.name); } // using forEach(...) people.forEach(person => { console.log(persone.id + ': ' + persone.name); }); // output of above two methods // 100: Vikash // 101: Sugam // 102: Ashish // forEach(...) with index people.forEach((person, index) => { console.log(index + ': ' + persone.name); }); // output of above code in console // 0: Vikash // 1: Sugam // 2: Ashish
javascript loop array
for (let step = 0; step < 5; step++) { // Runs 5 times, with values of step 0 through 4. console.log('Walking east one step'); }
Source: developer.mozilla.org
javascript loop array
??? ??? ??? ??? I suck
Source: web.roblox.com