Array and Boolean

One of the annoyances of old-school JavaScript was side effects; then Array.prototype got methods like filter, map, and forEach so we didn’t need to burn variables before looping over values.  I can’t explain how happy I am that the JavaScript language continues to evolve.

Every once in a while I need to filter an array by not its original value but instead a new value, so I use map: => {
    // Do whatever processing...

    // If we don't care about the item, return false or null or undefined
    return false;

While I get the new values I want, sometimes if an iteration returns a result I don’t want, I return null or false, which is great, but then I’m left with a bunch of useless items in the resulting array.

Check Full Content Here […] is Available for Purchase. Learn more by clicking the button here:

Get More Info