Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 538 Bytes

compact.md

File metadata and controls

32 lines (20 loc) · 538 Bytes

arrays.compact

compact(array)

Compact removes all falsy values [false, null, 0, "", undefined, NaN] from an array.

Arguments

  1. array (Array): input array

Returns

(Array): the input array w/ no falsy values

Example

const result = arrays.compact([1, false, 2, null, 3, 0, 4, "", 5, undefined, 6, NaN]);
console.log(result);
> [1, 2, 3, 4, 5, 6]