Book Image

Lo-Dash Essentials

By : Adam Boduch
Book Image

Lo-Dash Essentials

By: Adam Boduch

Overview of this book

Table of Contents (15 chapters)
Lo-Dash Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generic functions


Creating generic functions can make all the difference in the size and comprehensibility of our code. A generic function is useful in more than one context. It is loosely coupled to the application. That's what higher-level building blocks are all about; whether we're using a functional programming model, a more object-oriented approach, or a hybrid of the two, the key lies in generic components. As with most other aspects of programming, Lo-Dash provides many avenues to construct generic components. We'll address many of them throughout the course of this chapter. Let's start off by looking at functions that aren't so generic and how they compare with their more fluid cousins.

Specific functions

Whether a function is fit for one purpose or not, and whether it is fit for only one purpose, isn't always clear-cut. Depending on your perspective, there are degrees of specificity. Consider the following functions:

var collection = [
    { name: 'Ronnie', age: 43 },
    { name:...