every()、filter()、forEach()、map()、some()
array /boolean/none = array.every/filter/forEach/map/some(
function(element,index,arr){
procedures and return values;
}
);
// Run the following function for each item in the array, if all returns true , every returns true , if there is one item returns false , stop traversing every and return false ; if not written, the default returns false
array.every(function(item,index,arr) {
})
// Run the following function on each item in the array, which returns a new array of items whose result is true var arr = array.filter(function(item,index,arr) { }); console.log(arr);
// Traverse the array
array.forEach(function(item,index,arr){
});
// Run the following function on each item in the array and return a new array of the results of the function
var arr = array.map(function(item,index,arr) {
return "\"" + item + "\"";
})
// Run the following function on each item in the array, if the function returns true for an item , then some returns true
var b = array.some(function(item,index,arr) {
if (item == "ww" ) {
return true;
}
return false;
});