Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

map js

const arr = [1,2,3,4,5]

const modifiedArr = arr.map((val) => {    // takes callback and returns modified array
	return val * 5
})
// map doesn't modify original array!
// arr = [1,2,3,4,5]
// modifiedArr = [5,10,15,20,25]
Source by github.com #
 
PREVIOUS NEXT
Tagged: #map #js
ADD COMMENT
Topic
Name
1+5 =