Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useArrayJoin.md
1---2category: Array3---45# useArrayJoin67Reactive `Array.join`89## Usage1011### Use with array of multiple refs1213```ts14import { useArrayJoin } from '@vueuse/core'1516const item1 = ref('foo')17const item2 = ref(0)18const item3 = ref({ prop: 'val' })19const list = [item1, item2, item3]20const result = useArrayJoin(list)21// result.value: foo,0,[object Object]22item1.value = 'bar'23// result.value: bar,0,[object Object]24```2526### Use with reactive array2728```ts29import { useArrayJoin } from '@vueuse/core'3031const list = ref(['string', 0, { prop: 'val' }, false, [1], [[2]], null, undefined, []])32const result = useArrayJoin(list)33// result.value: string,0,[object Object],false,1,2,,,34list.value.push(true)35// result.value: string,0,[object Object],false,1,2,,,,true36list.value = [null, 'string', undefined]37// result.value: ,string,38```3940### Use with reactive separator4142```ts43import { useArrayJoin } from '@vueuse/core'4445const list = ref(['string', 0, { prop: 'val' }])46const separator = ref()47const result = useArrayJoin(list, separator)48// result.value: string,0,[object Object]49separator.value = ''50// result.value: string0[object Object]51separator.value = '--'52// result.value: string--0--[object Object]53```5455## Type Declarations5657```ts58export type UseArrayJoinReturn = ComputedRef<string>59/**60* Reactive `Array.join`61*62* @see https://vueuse.org/useArrayJoin63* @param list - the array was called upon.64* @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").65*66* @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.67*68* @__NO_SIDE_EFFECTS__69*/70export declare function useArrayJoin(71list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>,72separator?: MaybeRefOrGetter<string>,73): UseArrayJoinReturn74```75