Created
October 31, 2018 11:05
-
-
Save ufocoder/4e34ba6ebccd3eae8335581efa5338c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function multiply (multiplier) { | |
| return function (x) { | |
| return x * multiplier; | |
| }; | |
| } | |
| // ES6: | |
| // const multiply = x => y => x * y; | |
| const triple = multiply(3); | |
| const quadruple = multiply(4); | |
| const numbers = [1, 2, 3]; | |
| numbers.map(triple); // [3, 6, 9] | |
| numbers.map(quadruple); // [4, 8, 12] | |
| numbers.map(triple).map(quadruple); // [12, 48, 108] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment