_.compact

Creates an array with all falsy values removed.

  1. // Underscore/Lodash
  2. _.compact([0, 1, false, 2, '', 3]);
  3.  
  4. // Native
  5. [0, 1, false, 2, '', 3].filter(Boolean)

Browser Support for array.prototype.filter

ChromeEdgeFirefoxIEOperaSafari
1.5 ✔9.0 ✔