-
Book Overview & Buying
-
Table Of Contents
Lo-Dash Essentials
By :
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.
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: ...
Change the font size
Change margin width
Change background colour