Lodash 4 Cookbook
Lodash 4 Cookbook
For lodash 4.17.21
About the Book
In modern web development, JavaScript is a must-to-learn programming language. Using JavaScript is not an easy task. Most of JavaScript APIs are low-level APIs, which are hard to learn and use. Lodash is a popular JavaScript utility framework. It provides a lot of high-level APIs which are more convenient to remember and use. Developers can dramatically increase productivity by using lodash.
This book is a very good start point to learn lodash 4 and apply it in practice. It covers core concepts and functions provided by lodash with real examples. For some complicated functions, e.g. functions related to functional programming, this book has a more detailed explanation.
Most of the code examples are written as Jest test cases with ES6.
Lodash is no longer updating, so there won't be further updates to this book.
Table of Contents
-
1. Introduction
-
1.1 Installation
- 1.1.1 Web
- 1.1.2 NodeJS
- 1.2 Lodash features
- 1.3 Code sample convention
- 1.4 About this book
-
1.1 Installation
-
2. Common concepts
- 2.1 Truthy and falsy
- 2.2 SameValueZero
-
2.3 Predicates
-
2.3.1
matches
-
2.3.2
matchesProperty
-
2.3.3
property
-
2.3.1
-
2.4 Iteratees
- 2.4.1 Iteratee shorthand
-
2.5
this
binding
-
3. Collections
- 3.1 Each
- 3.2 Every and some
- 3.3 Filter and reject
- 3.4 Size
- 3.5 Includes
- 3.6 Sample
- 3.7 Shuffle
- 3.8 Partition
- 3.9 Count by
- 3.10 Group by and key by
-
3.11
invokeMap
-
3.12 Map and reduce
- 3.12.1 Map
- 3.12.2 Reduce
-
3.13 Search
-
3.13.1
find
-
3.13.2
findLast
-
3.13.1
- 3.14 Sort
-
3.15
flatMap
-
4. Arrays
- 4.1 Search
-
4.2 Set operations
- 4.2.1 Equality comparisons
- 4.2.2 Unique
- 4.2.3 Union
- 4.2.4 Difference
- 4.2.5 Intersection
- 4.2.6 Symmetric difference
- 4.3 Chunk
- 4.4 Compact
- 4.5 Fill
- 4.6 Flatten
-
4.7 Remove
-
4.7.1
remove
-
4.7.2
pull
-
4.7.3
pullAt
-
4.7.4
pullAll
-
4.7.5
without
-
4.7.1
-
4.8 Zip
-
4.8.1
zip
-
4.8.2
zipWith
-
4.8.3
zipObject
-
4.8.4
zipObjectDeep
-
4.8.5
unzip
-
4.8.1
-
4.9 Partition
-
4.9.1
first
-
4.9.2
last
-
4.9.3
initial
-
4.9.4
tail
-
4.9.1
-
4.10 Slicing
- 4.10.1 Basic slicing
- 4.10.2 Drop elements
- 4.10.3 Take elements
- 4.11 Sorted arrays
- 4.12 Concatenation
- 4.13 From pairs
- 4.14 Join
- 4.15 Reverse
- 4.16 Nth element
-
5. Objects
-
5.1 Assign
-
5.1.1
assign
-
5.1.2
assignIn
-
5.1.3
assignInWith
-
5.1.1
-
5.2 Merge
-
5.2.1
merge
-
5.2.2
mergeWith
-
5.2.1
- 5.3 Transform
- 5.4 Create
- 5.5 Default values
-
5.6 Function names
-
5.6.1
functions
-
5.6.2
functionsIn
-
5.6.1
-
5.7 Invert
-
5.7.1
invert
-
5.7.2
invertBy
-
5.7.1
-
5.8 Keys and values
-
5.8.1
has
-
5.8.2
hasIn
-
5.8.3
keys
andkeysIn
-
5.8.4
values
andvaluesIn
-
5.8.5
mapValues
-
5.8.6
mapKeys
-
5.8.7
result
-
5.8.8
toPairs
andtoPairsIn
-
5.8.1
-
5.9 Pick and omit
-
5.9.1
pick
andpickBy
-
5.9.2
omit
andomitBy
-
5.9.1
-
5.10 Iterate
-
5.10.1
forIn
andforInRight
-
5.10.2
forOwn
andforOwnRight
-
5.10.1
-
5.11 Get and set
-
5.11.1
get
-
5.11.2
set
-
5.11.3
setWith
-
5.11.4
update
-
5.11.1
- 5.12 At
- 5.13 Find key
-
5.1 Assign
-
6. Functions
- 6.1 Bind
-
6.2 Before and after
-
6.2.1
before
-
6.2.2
after
-
6.2.1
- 6.3 Ary
-
6.4 Partial
-
6.4.1
partial
-
6.4.2
partialRight
-
6.4.1
- 6.5 Curry
- 6.6 Flow
- 6.7 Defer
- 6.8 Once
- 6.9 Negate
- 6.10 Spread
- 6.11 Wrap
- 6.12 Rearg
- 6.13 Rest parameters
-
6.14 Debounce and throttle
- 6.14.1 Debounce
- 6.14.2 Throttle
- 6.15 Memoize
- 6.16 Modify arguments
- 6.17 Flip arguments
-
7. Strings
-
7.1 Character cases
-
7.1.1
capitalize
-
7.1.2
camelCase
-
7.1.3
snakeCase
-
7.1.4
kebabCase
-
7.1.5
startCase
-
7.1.1
- 7.2 Search
- 7.3 Escape
- 7.4 Pad
- 7.5 Trim
- 7.6 Repeat
- 7.7 Truncate
- 7.8 parseInt
- 7.9 Words
- 7.10 Replace
- 7.11 Split
-
7.12 Uppercase and lowercase
-
7.12.1
upperCase
-
7.12.2
upperFirst
-
7.12.3
toUpper
-
7.12.4
lowerCase
-
7.12.5
lowerFirst
-
7.12.6
toLower
-
7.12.1
-
7.1 Character cases
-
8. Miscellaneous
-
8.1 Types
- 8.1.1 Type check
- 8.1.2 Type conversion
- 8.2 Clone
- 8.3 Date
-
8.4 Math
- 8.4.1 Add
- 8.4.2 Subtract
- 8.4.3 Multiply
- 8.4.4 Divide
- 8.4.5 Max
- 8.4.6 Min
- 8.4.7 Sum
- 8.4.8 Ceil
- 8.4.9 Floor
- 8.4.10 Round
- 8.4.11 Mean
-
8.5 Number
-
8.5.1
inRange
-
8.5.2
clamp
- 8.5.3 Random numbers
-
8.5.1
-
8.6 Comparison
-
8.6.1
isEqual
andisEqualWith
-
8.6.2
eq
-
8.6.3
gt
andgte
-
8.6.1
-
8.7 Utilities
-
8.7.1
attempt
-
8.7.2
constant
-
8.7.3
identity
-
8.7.4
noop
-
8.7.5
noConflict
- 8.7.6 Range
-
8.7.7
times
-
8.7.8
uniqueId
- 8.7.9 Method
-
8.7.10
cond
-
8.7.11
conforms
-
8.7.12
nthArg
-
8.7.13
over
,overEvery
andoverSome
-
8.7.14
toPath
-
8.7.15
castArray
-
8.7.1
- 8.8 Stub
- 8.9 Default to
-
8.1 Types
-
9. Chaining
- 9.1 Wrapper
- 9.2 Explicit chaining
-
9.3
tap
-
9.4
thru
-
10. String Templates
- 10.1 interpolate
- 10.2 escape
- 10.3 evaluate
- 10.4 imports
- 10.5 Data object name
-
11. Recipes
-
11.1 Filter an object’s properties
- 11.1.1 Scenario
- 11.1.2 Solution
-
11.2 Push an array of elements into an array
- 11.2.1 Scenario
- 11.2.2 Solution
-
11.3 Process data for C3.js pie chart
- 11.3.1 Scenario
- 11.3.2 Solution
-
11.4 Create a unique array of objects
- 11.4.1 Scenario
- 11.4.2 Solution
-
11.5 Convert an array to an object
- 11.5.1 Scenario
- 11.5.2 Solution
-
11.1 Filter an object’s properties
- Notes
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them