Creates a slice of array from start up to, but not including, end. Part of Lodash Array since 3.0.0 (stable in 4.x — not deprecated). Note: Lodash uses this instead of native Array#slice to ensure a dense array is returned.
Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.slice on an array. Start with this line.
Lodash
_.slice(array, [start=0], [end=array.length])
Call
What it does
_.slice(array, [start=0], [end=array.length])
Primary signature.
_.slice(array)
Call with an array argument.
Prefer import slice from "lodash/slice" when you want a smaller bundle.
Library declarations
Lodash
_.slice(array, [start=0], [end=array.length])
Parameters
Parameter
Description
array
Required. Source to copy from
start
Optional. First index to include; default 0
end
Optional. Exclusive end; default array.length
Return Value
Return Value
Description
*
New dense array for that range
Lodash Examples
Example 1 — Slice From an Index
Omit end to copy from start through the last element.
New array.copy holds the same values in a new object.
Identity.copy === nums is false.
Shallow. Nested objects inside would still be shared.
Example 5 — Dense Copy of Sparse Array
Lodash returns a dense array — holes become defined undefined slots.
Lodash
var sparse = Array(3);
sparse[0] = "a";
sparse[2] = "c";
// sparse has a hole at index 1
var dense = _.slice(sparse);
console.log(1 in dense); // true (slot exists)
console.log(dense[1]); // undefined
Sparse source. Index 1 is a hole (1 in sparse is false).
Lodash note._.slice builds a dense result.
Defined slot.1 in dense is true; value is undefined.
Why. Predictable iteration and JSON-like behavior after the copy.
Compatibility
Browser & Runtime Support
_.slice is a Lodash 4.x Array helper (since 3.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Array.prototype.slice is also available in all modern (and many older) JS engines.
✓ Stable · Lodash 3.0.0+
_.slice()
Available in [email protected] full builds and the lodash/slice modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.sliceLodash 3.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import slice from "lodash/slice" for smaller builds — or native array.slice() when you do not need Lodash’s dense-array guarantee.
Frequently Asked Questions
_.slice(array, [start=0], [end=array.length]) creates a new array with elements from start up to, but not including, end. The source array is not mutated.
No. End is exclusive — same rule as native Array.prototype.slice. slice(arr, 1, 3) keeps indexes 1 and 2 only.
Negative start or end counts from the end of the array. -1 is the last element, -2 is second-to-last, and so on.
Range rules match. Lodash’s note is that _.slice ensures a dense array is returned — useful when copying sparse arrays so holes become defined undefined slots.
No. Slice is shallow: nested objects or arrays inside the window share references with the original.
Use import slice from "lodash/slice" or require("lodash/slice") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.slice.