Last active
July 4, 2020 15:42
-
-
Save julienetie/f97d3dd1fe57d5d618a964c267f21e72 to your computer and use it in GitHub Desktop.
ho-js-2.2.js
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
| /* Higher-Order JavaScript */ | |
| const rectangle = (height, width) => { | |
| const calcArea = () => height * width; | |
| return { | |
| get area(){ | |
| return calcArea(); | |
| }, | |
| calcArea | |
| } | |
| }; | |
| /* | |
| const square = rectangle(10, 10); | |
| console.log(square.area, square.calcArea()); // 100, 100 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment