JavaScript Array reduceRight()
The reduceRight() method runs a function on each array element to produce a single value.
The reduceRight() works from right-to-left in the array. See also reduce().
const numbers = [45, 4, 9, 16, 25];
let sum = numbers.reduceRight(myFunction);
function myFunction(total, value) {
return total + value;
}
JavaScript Array every()
The every() method checks if all array values pass a test.
const numbers = [45, 4, 9, 16, 25];
let allOver18 = numbers.every(myFunction);
function myFunction(value, index, array) {
return value > 18;
}
JavaScript Array some()
The some() method checks if some array values pass a test.
const numbers = [45, 4, 9, 16, 25];
let someOver18 = numbers.some(myFunction);
function myFunction(value, index, array) {
return value > 18;
}
JavaScript Array.from()
The from() method can return an array from any variable with a length property.
let text = "ABCDEFG";
Array.from(text);
Top comments (0)