Disclaimer: The road has a lot to learn referral of place, hope to help you on it! https://blog.csdn.net/mingzaiwang/article/details/78486971
ARR = var [1,2,3,4,5];
. 1, forEarh (so that each array do one thing)
arr.forEach (function (Item, index)) {
the console.log (Item);
}
2, Map (array allows the array to produce a new calculation by some)
var newArr = arr.map (function (Item, index)) {
rerurn Item * 2;
}
newArr => [2,4,6,8,10 ]
. 3, filter (a filter array qualified items to form a new array)
var newArr = arr.filter (function (item, index)) {
return item>. 3;
}
newArr => [4,5]
. 4, the reduce (let antecedent and do some items in the array is calculated, and the final accumulated value)
var arr.reduce Result = (function (PREV, Next)) {
return Next PREV +;
}
Result => 15;
. 5, Every ( each detection array eligibility)
var arr.every Result = (function (Item, index)) {
Item return> 0;
}
Result => to true (satisfied only for the whole to true);
. 6, (whether certain entries in the array detector matches) some
var arr.some Result = (function (Item, index)) {
return Item >. 1;
}
return => to true (that is, as long as a true).
. 1, forEarh (so that each array do one thing)
arr.forEach (function (Item, index)) {
the console.log (Item);
}
2, Map (array allows the array to produce a new calculation by some)
var newArr = arr.map (function (Item, index)) {
rerurn Item * 2;
}
newArr => [2,4,6,8,10 ]
. 3, filter (a filter array qualified items to form a new array)
var newArr = arr.filter (function (item, index)) {
return item>. 3;
}
newArr => [4,5]
. 4, the reduce (let antecedent and do some items in the array is calculated, and the final accumulated value)
var arr.reduce Result = (function (PREV, Next)) {
return Next PREV +;
}
Result => 15;
. 5, Every ( each detection array eligibility)
var arr.every Result = (function (Item, index)) {
Item return> 0;
}
Result => to true (satisfied only for the whole to true);
. 6, (whether certain entries in the array detector matches) some
var arr.some Result = (function (Item, index)) {
return Item >. 1;
}
return => to true (that is, as long as a true).