Today found JS a built-in function of reduce, still very interesting, write what I think the more interesting part
1. Reduce is often used for stacking arrays, he will accept two parameters, the first one is to destroy the function callback (), the second is the starting value (not required)
1 "does not pass a second parameter
var items=[1,4,5,7,89];
Items.reduce ((b) =>a+b)//106
2 "When the second parameter is passed
var items=[1,4,5,7,89];
Items.reduce ((b) =>a+b,100)//206
(in the case of pure numbers, it does anything that can be used for digital operation subtraction various)
2. If the array contains strings, you can also make the concatenation of strings, this time note that the callback function string concatenation is "+"
var items=[' 1 ', ' 4 ', ' 4 ', ' ee ', ' DSD '];
Items.reduce (function (A, b) {return a+b})//"144EEDSD"
JS built-in function reduce