Last active
July 4, 2020 15:45
-
-
Save julienetie/cb2b84ba2d5de11ea74c1dc4826a549d to your computer and use it in GitHub Desktop.
ho-js.7.js
This file contains 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
/* Pseudo-Functional JavaScript */ | |
const rec = height => width => ({ | |
get area (){return height * width} | |
}); | |
/* | |
// Assume 1 value is temporarily available | |
const calcArea = rec(10); | |
const square = calcArea(10); // Now the other arrives | |
console.log(square.area); // 100 | |
// Let's say I now need a memory efficient rectangle with a width of 20 | |
const rectangle = calcArea(20) | |
console.log(rectangle.area); // 200 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment