how to iterate through an array in javascript
array = [ 1, 2, 3, 4, 5, 6 ];
for (index = 0; index < array.length; index++) {
console.log(array[index]);
} const array = ["hello", "world"];
for (item of array) {
//DO THIS
}var colors = ["red","blue","green"];
colors.forEach(function(color) {
console.log(color);
});/* ES6 */
const cities = ["Chicago", "New York", "Los Angeles"];
cities.map(city => {
console.log(city)
})
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
Also in JavaScript:
- function click anywhere javascript
- javascript canvas clip rectangle
- id in class selector jquery
- javascript replace big list
- promise nodejs
- rangeSlider format price js
- jquery scrollHeight
- javascript array add end
- jquery add inline style
- javascript get first property of object
- butonc click jquery
- if json valide js
- javascript close current tab
- javascript new Regexp with flag
- open close children modal react
- javascript program german to english translation
- expo react native
- discord js channel connect
- jquery get element id
- how to replace characters in a string javascript
- how to check if array
- ejs if else
- electron file association
- ruby json delete key