You are viewing Pre-Alpha documentation.
Vuetify0 Logo

toArray

The toArray utility function provides a consistent way to convert any value into an array format. It handles edge cases like null and undefined values, and ensures that the output is always an array.

Usage

import { toArray } from '@vuetify/v0'

const value = 'Example Value'
const valueAsArray = toArray(value)

console.log(valueAsArray) // ['Example Value']

API

ComposableDescription
toReactive→Convert MaybeRef to reactive
useEventListener→Accepts single or array of events

toArray

  • Type

    function toArray<Z> (value: Z | Z[]): Z[]
  • Details

    Converts a value to an array. If the value is null or undefined, returns an empty array. If the value is already an array, returns it as-is. Otherwise, wraps the value in an array.

  • Example

    toArray('hello') // ['hello']
    toArray([1, 2, 3]) // [1, 2, 3]
    toArray(null) // []
    toArray(undefined) // []

© 2016-2025 Vuetify, LLC