Lodash _.compact() Method
The _.compact() method is used to create a new array by removing all falsy values from the given array. In JavaScript, the falsy values are – false, null, 0, “” (empty string), undefined, and NaN. Syntax Parameters Return Value It returns a new array after removing all falsy values from the original array. It preserves…