You are viewing Pre-Alpha documentation. Some features may not work as expected.

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
| Composable | Description |
|---|---|
| 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
nullorundefined, 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) // []