Lodash 4 Cookbook
Lodash 4 Cookbook
For lodash 4.17.10
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.
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
Other books by this author
Authors have earned$9,893,579writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
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), EPUB (for phones and tablets) and MOBI (for 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
Top Books
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
Introductory Statistics with Randomization and Simulation
Mine Cetinkaya-Rundel, Christopher Barr, OpenIntro, and David DiezA complete foundation for Statistics, also serving as a foundation for Data Science, that introduces inference using randomization and simulation while covering traditional methods.
Leanpub revenue supports OpenIntro, so we can provide free desk copies to teachers interested in using our books in the classroom.
More resources: openintro.org.
Java OOP Done Right
Alan MellorObject Oriented Programming is still a great way to create clean, maintainable code. But only if you use it right.
This book gives you 25 years of OO best practice, ready to use.
You'll learn to design objects behaviour-first, use TDD to help, then confidently apply Design Patterns, SOLID principles and Refactoring to make clean, crafted code.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Composing Software
Eric ElliottAll software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
Cloud Strategy
Gregor Hohpe“Strategy is the difference between making a wish and making it come true.” A successful migration to the cloud shouldn’t be driven by wishes, but guided by a sound strategy, frameworks, and decision models. This book tells you how—without becoming superficial nor getting lost in technology and product details.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #4
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #5
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #6
The Future of Digital Health
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer... - #7
Modern C++ by Nicolai Josuttis
2 Books
- #8
Django for Beginners/APIs/Professionals
3 Books
- #9
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #10
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...