O'Reilly logo
  • Stuart Felker thinks this is interesting:

let evens = Array.from(numbers, x => (x % 2 == 0));


Cover of Learning JavaScript Data Structures and Algorithms - Second Edition


The code didn't create an array of even numbers, it created a series of "true" and "false" entries. In order to get an array of even numbers, I had to use:

let evens = Array.from(numbers.filter( num => num % 2 == 0 ));