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

# take

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

## take<T>(array: Array<T>, n: 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 version 2.2.0._

### 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"]
```

## take(array: Null, n: Any): Null

Helper function that enables `take` to work with a `null` value.

_Introduced in DataWeave version 2.4.0._
