var fruits = ["apple", "orange", "cherry"]; fruits.forEach(getArrayValues); function getArrayValues(item, index) { console.log( index + ":" + item); } /* result: 0:apple 1:orange 2:cherry */