Skip to content

Instantly share code, notes, and snippets.

@julienetie
Last active July 4, 2020 15:42
Show Gist options
  • Select an option

  • Save julienetie/f97d3dd1fe57d5d618a964c267f21e72 to your computer and use it in GitHub Desktop.

Select an option

Save julienetie/f97d3dd1fe57d5d618a964c267f21e72 to your computer and use it in GitHub Desktop.
ho-js-2.2.js
/* 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