for array in js code example

Example 1: loop an array in javascript

let array = ["loop", "this", "array"]; // input array variable
for (let i = 0; i < array.length; i++) { // iteration over input
	console.log(array[i]); // logs the elements from the current input
}

Example 2: for array javascript

let iterable = [10, 20, 30];

for (let value of iterable) {
  value += 1;
  console.log(value);
}
// 11
// 21
// 31

Example 3: javascript iterate array

String[] myStringArray = {"Hello", "World"};
for (String s : myStringArray)
{
    // Do something
}