Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Arrow function in ES6

var array = [1, 2, 3, 4]

const sum = (acc, value) => acc + value
const product = (acc, value) => acc * value

var sumOfArrayElements = array.reduce(sum, 0)
var productOfArrayElements = array.reduce(product, 1)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Arrow #function
ADD COMMENT
Topic
Name
1+2 =