Skip to main content

join

join() function

Returns all elements in the given iterable into a string separated by separator.

Signature:

declare function join<A extends readonly []>(sep: string, iterable: A): "";

Returns:

""

Example

const joined = join('~', ['a', 'b', 'c']); // 'a~b~c'

// with pipe
pipe(
[1, 2, 3, 4],
map(a => a + 10),
filter(a => a % 2 === 0)
join('-'),
); // '12-14'

await pipe(
Promise.resolve([1, 2, 3, 4]),
join('-'),
); // '1-2-3-4'

// with toAsync
await pipe(
[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3), Promise.resolve(4)],
toAsync,
join('-'),
); // '1-2-3-4'