🌐 AI搜瓢 & 代理 主锵

Lodash

A modern JavaScript utility library delivering modularity, performance & extras.

_.defaults({Ā 'a':Ā 1Ā },Ā {Ā 'a':Ā 3,Ā 'b':Ā 2Ā });
// → {Ā 'a':Ā 1,Ā 'b':Ā 2Ā }
_.partition([1,Ā 2,Ā 3,Ā 4],Ā nĀ =>Ā nĀ %Ā 2);
// → [[1,Ā 3],Ā [2,Ā 4]]

Download

Lodash is released under the MIT license & supports modern environments. Review the build differences & pick one that’s right for you.

Installation

In a browser:

<scriptĀ src="lodash.js"></script>

Using npm:

$Ā npmĀ iĀ -gĀ npm
$Ā npmĀ iĀ --saveĀ lodash

In Node.js:

//Ā LoadĀ theĀ fullĀ build.
varĀ _Ā =Ā require('lodash');
//Ā LoadĀ theĀ coreĀ build.
varĀ _Ā =Ā require('lodash/core');
//Ā LoadĀ theĀ FPĀ buildĀ forĀ immutableĀ auto-curriedĀ iteratee-firstĀ data-lastĀ methods.
varĀ fpĀ =Ā require('lodash/fp');
Ā 
//Ā LoadĀ methodĀ categories.
varĀ arrayĀ =Ā require('lodash/array');
varĀ objectĀ =Ā require('lodash/fp/object');
Ā 
//Ā Cherry-pickĀ methodsĀ forĀ smallerĀ browserify/rollup/webpackĀ bundles.
varĀ atĀ =Ā require('lodash/at');
varĀ curryNĀ =Ā require('lodash/fp/curryN');

Note:
Install n_ for Lodash use in the Node.js < 6 REPL.

Why Lodash?

Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Lodash’s modular methods are great for:

Module Formats

Lodash is available in a variety of builds & module formats.

Complementary Tools

Further Reading

Support

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+.