Lodash

Lodash

Language
JavaScript
Category
2
Version
4.17.15
Authors
John-David Dalton
Description
Lodash is a JavaScript library which provides utility functions for common programming tasks using the functional programming paradigm.
Install Instructions
  • You can use lodash in a browser:
<script src="lodash.js"></script>
  • Or you can use npm and node.js:
$ npm i -g npm
$ npm i --save lodash
  • After installing with npm, you can load a variety of options:
// 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');
Usage
  • Array splitting example:
_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]
_.chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]
  • indexOf usage example:
_.indexOf([1, 2, 1, 2], 2); // => 1
  • forEach loop example:
_.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
console.log(key);
});
  • More examples are available in the documentation linked below.
Links