Skip to content

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

ParameterTypeDescription
thisreadonly unknown[]Array instance
separatorstringThe 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