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

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