How to get index of array element in map() function - JavaScript

 


To get index of array element in map() function - JavaScript

Let's take one Example:

let product = ['offer', 'warr', 'size', 'color', 'highlight', 'payops', 
                'services', 'spec'];

product.map((arrEle, index) => {
                            console.log(index); //index of array element 0,1,2,..
                            console.log(arrEle); //value of array element offer,..
                        })

Post a Comment

Previous Post Next Post