Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

flatmap javascript

var arr = [1, 2, 3, 4];

arr.flatMap(x => [x, x * 2]);
// is equivalent to
arr.reduce((acc, x) => acc.concat([x, x * 2]), []);
// [1, 2, 2, 4, 3, 6, 4, 8]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #flatmap #javascript
ADD COMMENT
Topic
Name
9+4 =