DEV Community

Discussion on: Simplify JavaScript Arrays

Collapse
 
jannikwempe profile image
Jannik Wempe • Edited

Thanks for this useful article :-)

You have a small type in your ES5 example for Array.every(): it should be age > 18.

I really love these methods in combination with higher order functions, e.g.:

let ages = [20, 25, 19, 21, 42];
let isGreaterThan = number => age => age > number;

console.log(ages.every(isGreaterThan(18)));
console.log(ages.every(isGreaterThan(19)));

It adds a lot to the reusability and readability of the code.

Collapse
 
helderberto profile image
Helder Burato Berto

I really appreciate your feedback, thanks for that! :)