What is the concept of Array.map?

前端 未结 8 1808
甜味超标
甜味超标 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:27

    Map function goes through each element of an array in ascending order and invokes function f on all of them. 
    It returns new array which is being computed after function is invoked on it.
    
    Ref: http://www.thesstech.com/javascript/array_map_method
    
    Syntax
    array.map(f)
    
    Example:
    
    
    
     
     
     
    
    
    Answer: 8,10,12
    Ref: http://www.thesstech.com/tryme?filename=javascript_array_map_method
    

提交回复
热议问题