Original author(s) | John-David Dalton |
---|---|
Initial release | April 23, 2012 |
Stable release |
4.17.4 / December 31, 2016
|
Development status | Active |
Written in | JavaScript |
Type | JavaScript library |
License | MIT |
Website | lodash |
Lodash is a JavaScript library which provides utility functions for common programming tasks using the functional programming paradigm.
Lodash draws most of its ideas from Underscore.js and now receives maintenance from the original contributors to Underscore.js.
Lodash is a JavaScript library that helps programmers write more concise and easier to maintain JavaScript.
It can be broken down into several main areas:
It has had multiple releases, so all functions may not be available in all implementations. For example, _.chunk has only been available since version 3.0.0.
The most up to date version of the function definitions are available from lodash.com/docs
Utilities:
Lodash has a group of general purpose utilities for simplifying common programming tasks.
Lang:
Math, Date, Number, and Util:
Properties and methods:
For example, a SpiderMonkey JavaScript implementation may be at an earlier version of Lodash than the latest one found in a major browser.
Function:
String:
Arrays:
Collections:
_.forEach(items, function(item, index) { // do stuff here; } ); will call the function passing in a single item and the index repeatedly for the whole collection.
Objects:
_.pick, _.omit, _.assingIn, _.transform, _.mapValues, etc.
Seq:
For example, to count the number of unique suites in my hand of cards. var myHand = ['club', 'diamond', 'diamond', 'club', 'spade']; _(myHand) .uniq() .size(); // 3
var myHand = ['club', 'diamond', 'diamond', 'club', 'spade']; _.chain(myHand) .uniq() .size() .value(); // 3