Sample Video Frame
27: Applying Functions
You don't have to use anonymous callback functions for data transformation. You can pass in more complex full functions to do the processing you need. You can also chain together calls to map
, reduce
, filter
, and find
to perform your transformations. In this code I do the calculation I want at the very end in one sequence of calls. You'll find when you get to Promises
that this is a common pattern.
You'll also see I threw in a debug
function, which is a handy trick for debugging these chains. All it does is print what it's given and return it.
The Code
Register for Learn JavaScript the Hard Way
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.