Awesome
Learning Lodash
Just one of the things I'm learning. https://github.com/hchiam/learning
Note: Lodash is is a superset of Underscore, so Lodash should be able to run everything that Underscore can, just require('lodash')
instead.
Tutorial: https://medium.com/voobans-tech-stories/10-lodash-functions-everyone-should-know-334b372aec5d
Lodash GitHub repo: https://github.com/lodash/lodash#lodash
Lodash API docs: https://lodash.com/docs/
Setup
npm install -g npm
npm install --save lodash
var _ = require('lodash');
// or
var _ = require('lodash/core');
// or
var array = require('lodash/array');
10 useful functions to know
(According to this Medium article:)
_.times(
n, [iteratee=_.identity])
_.find(
collection, [predicate=_.identity], [fromIndex=0])
_.debounce(
func, [wait=0], [options={}])
_.reduce(
collection, [iteratee=_.identity], [accumulator])
(Note: also works on objects!)
_.keyBy(
collection, [iteratee=_.identity])