Lodash _.take() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Creates a slice of array with n elements taken from the beginning. Part of Lodash 4.x Array — stable and non-mutating.

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.take on an array. Start with this line.

Lodash
_.take(array, [n=1])
CallWhat it does
_.take(array, [n=1])Primary signature.
_.take(array)Call with an array argument.

Prefer import take from "lodash/take" when you want a smaller bundle.

Library declarations
Lodash
_.take(array, [n=1])

Parameters

ParameterDescription
arrayRequired. Source to query
nOptional. Count to take from the start; default 1

Return Value

Return ValueDescription
*New array of up to n leading elements

Lodash Examples

Example 1 — Official: Default Take One

Omit n and Lodash keeps only the first element.

Lodash
_.take([1, 2, 3]);
// → [1]
Try It Yourself

How It Works

  1. Source. Array [1, 2, 3]; indexes 0 … 2.
  2. Default. Missing n means take 1 item.
  3. Keep head. Only 1 is included.
  4. New array. Result is [1] — not a bare value like _.head.

Example 2 — Official: Take a Specific Count

Pass n to keep several leading values in one call.

Lodash
_.take([1, 2, 3], 2);
// → [1, 2]
Try It Yourself

How It Works

  1. Ask for 2. Keep the first two slots.
  2. Kept. 1 and 2 form the result.
  3. Left out. 3 is beyond the prefix.
  4. Same as slice. Equivalent to [1, 2, 3].slice(0, 2).

Example 3 — Official: n Larger Than Length

Taking more items than exist returns the whole array.

Lodash
_.take([1, 2, 3], 5);
// → [1, 2, 3]
Try It Yourself

How It Works

  1. Ask for 5. Source only has 3 items.
  2. Clamp. Lodash stops at the end of the array.
  3. Result. All three values in a new array.
  4. Safe. No throw — oversized n is fine.

Example 4 — Official: Take Zero

n = 0 keeps nothing.

Lodash
_.take([1, 2, 3], 0);
// → []
Try It Yourself

How It Works

  1. Count is 0. No leading slots are requested.
  2. Empty slice. Result is [].
  3. Source safe. Original array is unchanged.
  4. Use. Handy when n comes from a variable that may be zero.

Example 5 — Empty Array

Taking from an empty source stays empty.

Lodash
_.take([], 2);
// → []
Try It Yourself

How It Works

  1. Empty source. No elements to keep.
  2. Result. Lodash returns [].
  3. Safe. No throw — fine in pipelines with optional data.
  4. Guard. Check length before assuming a prefix exists.

Browser & Runtime Support

_.take is a Lodash 4.x Array helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.x

_.take()

Available in [email protected] full builds and the lodash/take modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.x
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.take Lodash 4.x+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import take from "lodash/take" for smaller builds. Not a native browser API — load Lodash first.

Frequently Asked Questions

_.take(array, n) creates a new array with up to n elements from the start. The default for n is 1. The source array is not mutated.
No. Lodash returns a new array (a slice of the leading elements). The input stays unchanged.
When n is omitted, Lodash takes one element — the same everyday “first item only” case as _.head, but as a one-element array.
You get every element — a shallow copy of the whole array. Nothing throws.
You get an empty array []. Nothing is taken from the start.
Use import take from "lodash/take" or require("lodash/take") so bundlers can tree-shake. Full build: import _ from "lodash" then _.take.

Next: _.takeRight()

Keep a fixed number of elements from the end instead of the start.

_.takeRight() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful