_.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 });
// → { 'a': 1, 'b': 2, 'c': 3 }
_.map([1, 2, 3], function(n) { return n * 3; });
// → [3, 6, 9]
Review the build differences & pick the one that’s right for you.
CDN copies are available on cdnjs & jsDelivr.
Create custom builds with only the features you need.
Love modules? We’ve got you covered with lodash-amd, lodash-node, & npm packages per method.
Check out our unit tests, benchmarks, changelog, roadmap, as well as community created podcasts, posts, & videos.
In a browser:
<script src="lodash.js"></script>
In an AMD loader:
require(['lodash'], function(_) {/*…*/});
Using npm:
$ npm i --save lodash
$ {sudo -H} npm i -g lodash
$ npm ln lodash
In Node.js:
var _ = require('lodash');
// or as Underscore
var _ = require('lodash/dist/lodash.underscore');
Note:
Don’t assign values to the special variable “_” when in the REPL
_(…) supports intuitive chaining_.at for cherry-picking values_.bindKey for binding “lazy” defined methods_.clone supports shallow cloning of Date & RegExp objects_.cloneDeep for deep cloning arrays & objects_.contains accepts a fromIndex_.create for easier object inheritance_.curry for creating curried functions_.debounce & _.throttle accept additional options for more control_.findIndex & _.findKey for finding indexes & keys_.forEach supports exiting early_.forIn for iterating own & inherited properties_.forOwn for iterating own properties_.isPlainObject for checking if values are created by Object_.mapValues for mapping values to an object_.merge for a deep _.extend_.parseInt for consistent behavior_.pull & _.remove for mutating arrays_.random supports returning floating-point numbers_.sortBy supports sorting by multiple properties_.runInContext for collisionless mixins & easier mocking_.support for flagging environment features_.template supports “imports” options & ES6 template delimiters_.transform as a powerful alternative to _.reduce for transforming objects_.where supports deep comparisons_.xor as a companion to _.difference, _.intersection, & _.union_.clone, _.isEqual, & more accept callbacks_.contains, _.toArray, & more accept strings_.findLast, _.findLastIndex, & more right-associative methodsTested in Chrome (19, 36-37), Firefox (3, 20, 31-32), IE 6-11, Opera 23-24, Safari 5-7, Node.js 0.8.26~0.10.32, PhantomJS 1.9.7, RingoJS 0.9, & Rhino 1.7RC5.
Automated browser test runs are available as well as CI runs for lodash, lodash-cli, lodash-amd, lodash-node, & grunt-lodash. Special thanks to Sauce Labs for providing automated browser testing.