Like _.clone, except it accepts a customizer that may produce the cloned value. If the customizer returns undefined, Lodash handles cloning instead. Part of Lodash Lang since 4.0.0 (stable — not deprecated). Warning: cloning is shallow — nested objects stay shared unless you replace them.
Pass the value you want to inspect or convert. Read the return type carefully before you use the result.
Syntax
Call _.cloneWith. Start with this line.
Lodash
_.cloneWith(value, [customizer])
Call
What it does
_.cloneWith(value, [customizer])
Primary signature.
_.cloneWith(value)
Check, compare, clone, or convert a value.
Prefer import cloneWith from "lodash/cloneWith" when you want a smaller bundle.
Library declarations
Lodash
_.cloneWith(value, [customizer])
Parameters
Parameter
Description
value
Required. Value to clone
customizer
Optional. Hook invoked as (value [, index|key, object, stack])
Return Value
Return Value
Description
*
Cloned value (customized where you returned a value)
Lodash Examples
Example 1 — Shallow Clone: Nested Refs Stay Shared
Top-level object is new; nested objects keep the same reference.
Same hook style. Both accept a customizer; both return undefined here.
Shallow.cloneWith copies only the top level → nest is shared.
Deep.cloneDeepWith recurses → nest is a new object.
Pick. Need nested independence? Prefer cloneDeepWith.
Compatibility
Browser & Runtime Support
_.cloneWith is a Lodash 4.x Lang helper (since 4.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines have object spread / Object.assign, but not this customizer-based shallow clone by name.
✓ Stable · Lodash 4.0.0+
_.cloneWith()
Available in [email protected] full builds and the lodash/cloneWith 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
_.cloneWithLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import cloneWith from "lodash/cloneWith" for smaller builds. Not a native browser API — load Lodash first.
Frequently Asked Questions
_.cloneWith(value, [customizer]) is like _.clone, but accepts a customizer. The customizer can produce the cloned value; if it returns undefined, Lodash handles cloning with its default shallow rules.
It is shallow. Nested objects and arrays remain shared with the source unless your customizer returns a replacement for them.
Lodash uses its default shallow cloning behavior for that value. Return any other value (including null or 0) to use it as the clone.
clone uses fixed shallow rules only. cloneWith adds a customizer hook so you can override how certain values are copied.
Use cloneDeepWith when you need recursion plus customization across the whole nested tree.
Use import cloneWith from "lodash/cloneWith" or require("lodash/cloneWith") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.cloneWith.