Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

foreach method of array in javascript

// foreach method of array in javascript
let numberArray = [1,2,3,4,5];
function printArrayValue(value, index){
    console.log(`value: ${value} = index: ${index}`);
}
numberArray.forEach(printArrayValue);
// Output:
// value: 1 = index: 0
// value: 2 = index: 1
// value: 3 = index: 2
// value: 4 = index: 3
// value: 5 = index: 4
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #foreach #method #array #javascript
ADD COMMENT
Topic
Name
5+6 =