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

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