What is the concept of Array.map?

前端 未结 8 1809
甜味超标
甜味超标 2020-11-30 06:36

I am having problems understanding the concept of Array.map. I did go to Mozilla and Tutorials Point, but they provided very limited info regarding this.

<
8条回答
  •  鱼传尺愫
    2020-11-30 07:21

    IF you have an array of elements and you have to perform the same operation on the each element of the array that time you can use the javascript map function for array it helps to iterate throw the array then we can perform the operation of each element and return it.

    let NumberArray = [1,2,3,4,5,6,7,8];
    
    let UpdatedArray = NumberArray.map( (Num , index )=>{ 
                    return Num*10;
                })
    
    console.log(UpdatedArray);
    
    //UpdatedArray ==> [10, 20, 30, 40, 50, 60, 70, 80]
    

提交回复
热议问题