Skip to content

Instantly share code, notes, and snippets.

@jsatk
Last active January 17, 2018 00:38
Show Gist options
  • Save jsatk/36a783450a412230861605ef5c2691b6 to your computer and use it in GitHub Desktop.
Save jsatk/36a783450a412230861605ef5c2691b6 to your computer and use it in GitHub Desktop.
const rectangle = (height, width) => ({
height,
width,
get area() {
return height * width;
}
});
const myRectangle = rectangle(10, 20);
myRectangle.area // => 200
myRectangle.height // => 10
myRectangle.width // => 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment