nonNullishJoin()
ts
function nonNullishJoin(this, separator): string;Defined in: array/join.ts:19
Joins array elements into a string, automatically skipping null and undefined values.
Parameters
| Parameter | Type | Description |
|---|---|---|
this | readonly unknown[] | Array instance |
separator | string | The string to insert between array elements |
Returns
string
A string with all non-nullish array elements joined by the separator.
Example
ts
const array = [1, "a", undefined, "b", 3,, null];
const joined = array.nonNullishJoin(",");
console.assert(joined === "1,a,b,3,");Since
1.0.0
Author
Simon Kovtyk