all AI news
Ways to Iterate JavaScript Arrays
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 kiwi loop programming through
More from pub.towardsai.net / Towards AI - Medium
Jobs in AI, ML, Big Data
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
Senior Principal, Product Strategy Operations, Cloud Data Analytics
@ Google | Sunnyvale, CA, USA; Austin, TX, USA
Data Scientist - HR BU
@ ServiceNow | Hyderabad, India