in how many way i can traverse the array in javascript code example
Example 1: how to iterate through an array in javascript
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
Example 2: how to loop through an array
int[] numbers = {1,2,3,4,5};
for (int i = 0; i < numbers.length; i++) {
System.out.println(i);
}