Sept. 6, 2023, 10:02 p.m. | Vivek Chaudhary

Towards AI - Medium pub.towardsai.net

The objective of this article is to understand different possible ways to loop through JavaScript Arrays.

Declare array

const arr=[‘kiwi’,’dragon’,’orange’,’apple’,’pomegranate’];
const sal=[2200,5000,2100,1500,3700,4300];
let sal_incr=[]

for() loop

for loop is an iterative statement, it checks for some conditions and then executes a block of code repeatedly as long as those conditions are met.

console.log(“Arrays for loop”)

for (let i=0;i<arr.length;i++){
console.log(arr[i])
}

Output:

for..in loop

for…in loop is an easier way to loop through arrays as it gives us the key which …

apple arr arrays article checks code coding dragon iterate iterative javascript javascript-development javascript-tips kiwi loop programming through

More from pub.towardsai.net / Towards AI - Medium

Senior AI/ML Developer

@ Lemon.io | Remote

Senior Applied Scientist

@ Tractable | London, UK

Senior Data Scientist, Product (Pro Growth)

@ Thumbtack | Remote, Ontario

Specialist Solutions Architect - Data Science / Machine Learning

@ Databricks | United States

Specialist Solutions Architect - Data Engineering (Financial Services)

@ Databricks | United States

Data Engineer I (R-15080)

@ Dun & Bradstreet | Hyderabad - India