---
name: "up.util.wrapList"
area: "API"
kind: "JavaScript function"
parent: "up.util module"
url: "https://unpoly.com/api/up.util.wrapList"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.util module](https://unpoly.com/api/up.util.md)</nav>

# up.util.wrapList(value)

Returns the given value if it is [array-like](https://unpoly.com/api/List.md), otherwise returns an array with the given value as its only element.

Returns an empty array if called with `null` or `undefined`.

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Parameters](#parameters)
- [Return value](#return-value)

</nav>

## Example {#example}

```js
up.util.wrapList([1, 2, 3]) // result: [1, 2, 3]
up.util.wrapList('foo') // result: ['foo']
up.util.wrapList(undefined) // result: []
up.util.wrapList(null) // result: []
```

---

## Parameters {#parameters}

### value {#value}

(required)

Type: any

---

## Return value {#return-value}

Type: [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) | [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) | [jQuery](https://learn.jquery.com/using-jquery-core/jquery-object/)

