javascript map function index code example
Example 1: es6 map usin index
const array = [1, 2, 3, 4];
const map = array.map((x, index) => {
console.log(index);
return x + index;
});
console.log(map);
Example 2: how the map function works javascript
const array = [2, 5, 9];
let squares = array.map((num) => num * num);
console.log(array); // [2, 5, 9]
console.log(squares); // [4, 25, 81]
Example 3: map method
var yourArray= yourArray.map(Number);