Manually creating compositions can be cumbersome if there are many situations where functions need to be combined. Kyle explains how to create a compose2() function that will take two functions as arguments and return a composition.
(audio logo)…- There are ways to extrapolate composition…to a very general sense.…And we're not going to try to go very deep down…that rabbit hole, because there's actually…a whole bunch of complexity, here,…that I have not personally found to be very useful…in my programs.…But I do just want to take you slightly…into the rabbit hole so you understand…a little bit of how that mindset works.…What if I wanted to create myself…a slightly more generic utility, a compose utility.…Rather, I'll call it a compose two utility,…which composes just two functions,…and it makes some assumptions…about what arguments are passed.…
What if I wanted to make that sort of reusable utility.…I could declare a compose two function…as I'm doing here on line nine.…It takes a function one and a function two.…And you'll notice that the first thing it does…is create a new function that returns back.…Uh oh, that's...…That's a different pattern than we've seen so far yet.…That's a pattern that's going to harken forward…to what we're talking about when we talk about closure.…
This course was created by Frontend Masters. It was originally released on 03/08/2016. We're pleased to host this training in our library.
- Pure functions
- Manual composition
- Composition utility
- List operations
Skill Level Intermediate
1. Pure Functions
2. Composition and Immutability
3. Closure and Recursion
4. List Operations
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.