January 2019
Beginner
210 pages
4h 47m
English
Functional composition is a technique or pattern that allows us to combine multiple functions to create a more complex function.
The following code snippet declares two simple functions:
const trim = (s: string) => s.trim();const capitalize = (s: string) => s.toUpperCase();
That two simple functions declared by the preceding code snippet are the following:
We can create a function that performs both of the preceding operations by composing them as follows:
const trimAndCapitalize = (s: string) => capitalize(trim(s));
trimAndCapitalize is a function that invokes the trim function (using s as its argument) and passes its return to the ...
Read now
Unlock full access