[undefined, null, "", 0, false, NaN]
Example usage:
import { compact } from "@thalesrc/js-utils/array"; const arr = [undefined, "", false, 0, 1, "1"]; const compacted = compact(arr); // [1, "1"];
Example as Array Prototype:
import "@thalesrc/js-utils/array/proto/compact"; const arr = [undefined, "", false, 0, 1, "1"]; const compacted = arr.compact(); // [1, "1"];
type of array
array to compact
a new compacted array
Generated using TypeDoc
Filters falsy values of the given array
[undefined, null, "", 0, false, NaN]
Example usage:
import { compact } from "@thalesrc/js-utils/array"; const arr = [undefined, "", false, 0, 1, "1"]; const compacted = compact(arr); // [1, "1"];
Example as Array Prototype:
import "@thalesrc/js-utils/array/proto/compact"; const arr = [undefined, "", false, 0, 1, "1"]; const compacted = arr.compact(); // [1, "1"];