Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Lo-Dash Essentials
  • Table Of Contents Toc
Lo-Dash Essentials

Lo-Dash Essentials

By : Adam Boduch
4.8 (8)
close
close
Lo-Dash Essentials

Lo-Dash Essentials

4.8 (8)
By: Adam Boduch

Overview of this book

If you are a curious JavaScript developer interested simultaneously in tweaking the efficiency of your code, as well as improving the conciseness of it, and maintaining the readability of it, then this is the book for you. Ideally, the book is intended for readers already working on JavaScript projects and using frameworks such as jQuery and Backbone. Even if you're already using Lo-Dash, this book will show you how to use it efficiently. While extensive JavaScript experience isn't a requirement, you should have at least some prior programming experience in order to best understand the concepts presented.
Table of Contents (10 chapters)
close
close
9
Index

Reducing objects


In this section, we will turn our attention to reducing objects and working with object accumulators. Reducing objects is a lot like reducing arrays, the difference being that you have a key instead of an index. Oh yeah, there's also the ordering, which is kind of important—arrays are ordered, objects aren't.

Previously in the chapter, we caught a glimpse of what accumulators are. Here we'll take a deeper look at object accumulators, including some of the built-in Lo-Dash functions that utilize this concept.

Reducing keys

You can reduce an object to something different based solely on its keys. For example, if there are only certain properties you need, you can reduce the object to include only those properties, using the following code:

var object = { 
        first: 'Kerry',
        last: 'Singleton',
        age: 41
    },  
    allowed = [ 'first', 'last' ];

_.reduce(object, function(result, value, key) {
    if (_.contains(allowed, key)) {
        result[key] = value;...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Lo-Dash Essentials
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon