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

# 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._
