Skip to content

Instantly share code, notes, and snippets.

@julienetie
Last active July 4, 2020 15:45
Show Gist options
  • Save julienetie/cb2b84ba2d5de11ea74c1dc4826a549d to your computer and use it in GitHub Desktop.
Save julienetie/cb2b84ba2d5de11ea74c1dc4826a549d to your computer and use it in GitHub Desktop.
ho-js.7.js
/* 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