1<!doctype html><html class=home lang=en><meta charset=utf-8><meta content="A JavaScript utility library delivering consistency, modularity, performance, & extras." name=description><meta content=#3492ff name=theme-color><meta content="width=device-width,initial-scale=1" name=viewport><title>Lodash</title><link href=/icons/apple-touch-180x180.png rel=apple-touch-icon sizes=180x180><link href=https://github.com/lodash/lodash/commits/master.atom rel=feed type=application/atom+xml><link href=/icons/favicon-32x32.png rel=icon sizes=32x32 type=image/png><link href="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVMaXExk//ImxjuAAAAAXRSTlMAQObYZgAAAA9JREFUeAFjIBLU/2MC0wALJgGAaiAmLQAAAABJRU5ErkJggg==" rel=icon sizes=16x16 type=image/png><link href=/manifest.webmanifest rel=manifest><link href=/icons/safari-pinned-tab-16x16.svg rel=mask-icon color=#3492ff><link href=/docs/4.18.1 rel=prerender pr=1.0><link href=/assets/css/main.css rel=stylesheet><noscript><link href=/vendor/cdn.jsdelivr.net/fontawesome/4.7.0/css/font-awesome.min.css rel=stylesheet></noscript>
1<script async src=/assets/js/boot.js></script>
1<body class=layout-default><header><div class=container><div class="header-section logo-section"><div class=logo><a href=/ title=Lodash>Lodash</a></div><div class=header-group><h1>Lodash</h1><h2>A modern JavaScript utility library delivering modularity, performance & extras.</h2></div></div><div class=header-section><a href=/docs/ class="btn primary">Documentation</a> <a href=https://github.com/lodash/lodash/wiki/FP-Guide class=btn>FP Guide</a> <a href=/version-support class=btn>Version Support</a></div></div></header><div class="container main"><section><div class="highlight js intro"><pre><div>_<span class="delimiter method">.</span><span class=name>defaults</span>({ <span class=string>'a'</span>: <span class=numeric>1</span> }<span class=delimiter>,</span> { <span class=string>'a'</span>: <span class=numeric>3</span><span class=delimiter>,</span> <span class=string>'b'</span>: <span class=numeric>2</span> });</div><div><span class=comment>// â { 'a': 1, 'b': 2 }</span></div><div>_<span class="delimiter method">.</span><span class=name>partition</span>([<span class=numeric>1</span><span class=delimiter>,</span> <span class=numeric>2</span><span class=delimiter>,</span> <span class=numeric>3</span><span class=delimiter>,</span> <span class=numeric>4</span>]<span class=delimiter>,</span> n <span class=type>=></span> n % <span class=numeric>2</span>);</div><div><span class=comment>// â [[1, 3], [2, 4]]</span></div></pre></div></section><section><h2>Download</h2><ul id=download-links><li><i class="fa fa-download" aria-hidden=true></i><a href=https://raw.githubusercontent.com/lodash/lodash/4.18.1-npm/core.js>Core build</a> (<a href=https://raw.githubusercontent.com/lodash/lodash/4.18.1-npm/core.min.js>~4kB gzipped</a>)<li><i class="fa fa-download" aria-hidden=true></i><a href=https://raw.githubusercontent.com/lodash/lodash/4.18.1-npm/lodash.js>Full build</a> (<a href=https://raw.githubusercontent.com/lodash/lodash/4.18.1-npm/lodash.min.js>~24kB gzipped</a>)<li><i class="fa fa-link" aria-hidden=true></i><a href=https://www.jsdelivr.com/projects/lodash>CDN copies</a></ul><p><span class=rwd-line>Lodash is released under the <a href=https://raw.githubusercontent.com/lodash/lodash/4.18.1-npm/LICENSE>MIT license</a> & supports modern environments.</span> <span class=rwd-line>Review the <a href=https://github.com/lodash/lodash/wiki/Build-Differences>build differences</a> & pick one thatâs right for you.</span></section><section><h2>Installation</h2><p>In a browser:<div class="highlight html"><pre><script src=<span class=string>"lodash.js"</span>></script></pre></div><p>Using npm:<div class="highlight shell"><pre><div>$ npm i -g npm</div><div>$ npm i --save lodash</div></pre></div><p>In Node.js:<div class="highlight js"><pre><div><span class=comment>// Load the full build.</span></div><div><span class=type>var</span> _ = <span class=support>require</span>(<span class=string>'lodash'</span>);</div><div><span class=comment>// Load the core build.</span></div><div><span class=type>var</span> _ = <span class=support>require</span>(<span class=string>'lodash/core'</span>);</div><div><span class=comment>// Load the FP build for immutable auto-curried iteratee-first data-last methods.</span></div><div><span class=type>var</span> fp = <span class=support>require</span>(<span class=string>'lodash/fp'</span>);</div><div> </div><div><span class=comment>// Load method categories.</span></div><div><span class=type>var</span> array = <span class=support>require</span>(<span class=string>'lodash/array'</span>);</div><div><span class=type>var</span> object = <span class=support>require</span>(<span class=string>'lodash/fp/object'</span>);</div><div> </div><div><span class=comment>// Cherry-pick methods for smaller browserify/rollup/webpack bundles.</span></div><div><span class=type>var</span> at = <span class=support>require</span>(<span class=string>'lodash/at'</span>);</div><div><span class=type>var</span> curryN = <span class=support>require</span>(<span class=string>'lodash/fp/curryN'</span>);</div></pre></div><p><strong>Note:</strong><br>Install <a href=https://www.npmjs.com/package/n_>n_</a> for Lodash use in the Node.js < 6 REPL.</section><section><h2>Why Lodash?</h2><p><span class=rwd-line>Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, str
1ings, etc.</span> <span class=rwd-line>Lodashâs modular methods are great for:</span><ul class=chevron><li>Iterating arrays, objects, & strings<li>Manipulating & testing values<li>Creating composite functions</ul></section><section><h2>Module Formats</h2><p>Lodash is available in a <a href=/custom-builds>variety of builds</a> & module formats.<ul class=chevron><li><a href=https://www.npmjs.com/package/lodash>lodash</a> & <a href=/per-method-packages>per method packages</a><li><a href=https://www.npmjs.com/package/lodash-es>lodash-es</a>, <a href=https://www.npmjs.com/package/babel-plugin-lodash>babel-plugin-lodash</a>, & <a href=https://www.npmjs.com/package/lodash-webpack-plugin>lodash-webpack-plugin</a><li><a href=https://github.com/lodash/lodash/tree/4.18.1-npm/fp>lodash/fp</a><li><a href=https://www.npmjs.com/package/lodash-amd>lodash-amd</a></ul></section><section><h2>Complementary Tools</h2><ul class=chevron><li><a href=https://github.com/smartprocure/futil-js>futil-js</a> is a set of functional utilities designed to complement lodash</ul></section><section><h2>Further Reading</h2><ul class=chevron><li><a href=https://github.com/lodash/lodash/blob/master/.github/CONTRIBUTING.md>Contributing</a><li><a href=https://github.com/lodash/lodash/releases/tag/4.0.0>Release Notes</a><li><a href=https://github.com/lodash/lodash/wiki>Wiki (Changelog, Roadmap, etc.)</a></ul></section><section><h2>Support</h2><p><span class=rwd-line>Tested in Node.js 4+, Bun 1.0+, and the latest Chromium, Firefox, WebKit, and Edge via Playwright, with a best-effort commitment to support Chrome 74+, Firefox 66+, IE 11, Edge 18, and Safari 11+.</span></section>
1<script async src=/assets/js/home.js></script>
1</div><footer><div class=container><p>Site made with <i class="fa fa-heart" aria-label=love></i> by <a href=https://twitter.com/veksenn>@veksenn</a> & <a href=https://twitter.com/ZTHall>@zthall</a>.<p>Maintained by the <a href=https://github.com/orgs/lodash/people>core team</a> with help from <a href=https://github.com/lodash/lodash/graphs/contributors>our contributors</a>.</div></footer>
1<script async src=/vendor/cdn.jsdelivr.net/npm/[email protected]/lodash.js></script>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.