GeezerVison is showing github.com — Improved readability of HOF transition · atik2002/javascript@6aa0e89
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: functions/higher_order.md +2-4Lines changed: 2 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -33,11 +33,9 @@ map(add_2, [5,6,7]) // => [7, 8, 9] |
33 | 33 | map(double, [5,6,7]) // => [10, 12, 14] |
34 | 34 | ``` |
35 | 35 |
|
36 | | -The functions in the above example were intentionally simple, |
37 | | -and serves to illustrate that passing functions as arguments |
38 | | -to other functions allows for flexibility when building things. |
| 36 | +The functions in the above example are simple. However, when passed as arguments to other functions, they can be composed in unforeseen ways to build more complex functions. |
39 | 37 |
|
40 | | -For example, if we notice that we use the invocations `map(add_2, ...)` and `map(double, ...)` very often in our code, we could decide we want to create two special-purpse list processors that have the desired operation baked into them. Using function composition, we could do this as follows: |
| 38 | +For example, if we notice that we use the invocations `map(add_2, ...)` and `map(double, ...)` very often in our code, we could decide we want to create two special-purpse list processing functions that have the desired operation baked into them. Using function composition, we could do this as follows: |
41 | 39 |
|
42 | 40 | ```javascript |
43 | 41 | process_add_2 = function(list) { |
|