-
Book Overview & Buying
-
Table Of Contents
Lo-Dash Essentials
By :
A decorator does what the name implies. It decorates functions with additional capabilities. It's like an adornment for a piece of functionality. For example, let's say we've already implemented a function that looks up data in some structure. It's already used throughout our application, but now we're implementing a new component that requires this same functionality and something extra. We can use the function-decorating tools provided by Lo-Dash to take existing functions and extend them.
There are two flavors of Lo-Dash function decoration: Partials, which construct new functions that have the arguments of the original function partially supplied, and Wrappers, which build a new function that wraps the original function with a whole new function.
To create a partial function using Lo-Dash, you use the partial() function. The resulting function then has some arguments presupplied—we don't have to supply them again when...
Change the font size
Change margin width
Change background colour