---
schema_version: "1"
id: a4ccfc69e3f9a9fdf28a7dbcc60f15ea794c8756e974a12fa6f77adb61d264a2
title: take
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.3/dw-arrays-functions-take.md
canonical_url: https://docs.mulesoft.com/dataweave/2.3/dw-arrays-functions-take
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 13f2cad030733d8a3e0c983fbcdbe54db433cf66611b19c4433ddb6ccd147f1f
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: DataWeave
version: 2.3
---

# take

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## take(Array<T>, Number): Array<T>

Selects the first `n` elements. It returns an empty array when `n <= 0` and the original array when
`n > sizeOf(array)`.

_Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>array</code></p></td><td><p>The array of elements.</p></td></tr><tr><td><p><code>n</code></p></td><td><p>The number of elements to select.</p></td></tr></tbody></table>

### Example

This example outputs an array that contains the values of first two elements of the input array.

#### Source

```DataWeave
 %dw 2.0
 import * from dw::core::Arrays
 var users = ["Mariano", "Leandro", "Julian"]
 output application/json
 ---
 take(users, 2)
```

#### Output

```json
["Mariano", "Leandro"]
```
