compact
优质
小牛编辑
139浏览
2023-12-01
Creates a new sequence with the same elements as this one, except for all falsy VALUES (NULL, 0
, ""
, null
, and undefined
).
Signature
Sequence.compact = function() { /*...*/ }
Sequence.compact = function compact() { return this.filter(function(e) { return !!e; }); }
Name | Type(s) | Description |
---|---|---|
returns | Sequence | The new sequence. |
Examples
Lazy(["foo", null, "bar", undefined]).compact() // sequence: ["foo", "bar"]