The array to compact.
A new array containing only the truthy values from the original array.
This utility is useful for cleaning up arrays where you want to remove unwanted or non-useful values, such as when processing user input or filtering results.
Filters out falsy values from an array, returning a new array with only truthy values. This includes removing
null
,undefined
,false
,0
, and empty strings.