Learn, grow and help others with BBBootstrap
Contribute us with some awesome cool snippets using HTML,CSS,JAVASCRIPT and BOOTSTRAP
![](https://i.imgur.com/dnN38NC.jpg)
In javascript, there are many ways to iterate through the array. In this example, we will use for...of
function.
const alpha = ['ABC', 'EFG','IJK','LMN']; for (const alphas of alpha) { console.log(alpha); }
Here we can use map function to iterate through the array.
const alpha = ['ABC', 'EFG','IJK','LMN']; alpha.map((values)=>{ console.log(values); });
Iterating using the ForEach loop function
const alpha = ['ABC', 'EFG','IJK','LMN']; alpha.forEach(values => { console.log(values) ; })
Old For loop approach can be used. but not recommended in modern JavaScript ES6. Code is below
const alpha = ['ABC', 'EFG','IJK','LMN']; for (let index = 0; index < alpha.length; ++index) { const element = alpha[index]; console.log(element); }