R
fn

useArrayJoin

v0.0.15testeddemo

Reactive `Array.prototype.join`, with an optional reactive separator.

Example

ts
const list = ref(['a', 'b', 'c']);
const sep = ref('-');
const joined = useArrayJoin(list, sep); // 'a-b-c'

Demo

Loading demo…

Signature

ts
export function useArrayJoin(
  list: MaybeRefOrGetter<Array<MaybeRefOrGetter<unknown>>>,
  separator?: MaybeRefOrGetter<string>,
): UseArrayJoinReturn{ ... }

Parameters

ParameterTypeDescription
listMaybeRefOrGetter<unknown[]>The source array (items can be reactive)
separator?MaybeRefOrGetter<string> | undefinedA reactive separator placed between adjacent elements (defaults to `,`)

Returns

UseArrayJoinReturnA computed string of all elements joined; empty string when the array is empty