Call once._.noConflict() returns the Lodash function.
Save it. Store the result in lodash.
Use it.lodash.map doubles each number → [2, 4, 6].
Global._ is no longer Lodash — do not call _ for Lodash APIs.
Example 2 — Restore a Legacy _
When another library owned _ first, noConflict gives it back.
Lodash
// pretend a legacy lib already set window._
window._ = {
library: 'legacy',
greet: function () { return 'from legacy'; }
};
// then Lodash loads and overwrites _
// (in the Try It lab, Lodash loads after the stub)
var lodash = _.noConflict();
_.greet(); // → 'from legacy'
lodash.sum([1, 2, 3]); // → 6
noConflict. Gives up global _; you keep one Lodash handle.
runInContext. Builds a private Lodash without restoring _.
Mixins. Extend the isolated copy so the shared API stays clean.
Pick. Name clash → noConflict; plugin isolation → runInContext.
Compatibility
Browser & Runtime Support
_.noConflict is a Lodash Util helper (stable). It is meaningful mainly in browsers with a global _. In Node / Bun / Deno, prefer require or import — no global clash to resolve.
✓ Stable · Script-tag utility
_.noConflict()
Available in [email protected] full builds loaded via CDN or script tag. Modular imports already avoid window._ conflicts.
100%With full Lodash build
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
_.noConflictFull Lodash build
Bottom line: Use in browser pages that share global _. Prefer import/require in modern apps. Always assign the return value once.
Frequently Asked Questions
_.noConflict() restores the global _ variable to whatever it was before Lodash loaded, and returns the Lodash function. Capture it: var lodash = _.noConflict(); then call lodash.map(...).
No. Call it once and assign the return value. After the first call, global _ is no longer Lodash, so a second call can fail or return the wrong thing.
Mostly with browser script tags when another library (often Underscore) also uses _. With npm or ES module imports, each file has its own binding — noConflict is rarely needed.
No. It only frees the global _ name. Lodash still works through the variable you saved from the return value.
noConflict restores the previous global _. runInContext creates a separate Lodash copy without giving up the global — better for plugins and isolated mixins.
No. It is a stable Lodash Util method. Prefer module imports in modern apps; use noConflict for script-tag name clashes.