Dana Woodman
1 min readMar 15, 2018

--

Interest concept, going to consider if this is something I want to use in future work.

One suggestion to simplify your final example, instead of:

function makeShoppingCart({ 
addProduct,
empty,
getProducts,
removeProduct,
...others
}) {
return Object.freeze({
addProduct,
empty,
getProducts,
removeProduct,
someOtherMethod,
...others
)}
function someOtherMethod () {
// code
}
}

You could simply do:

function makeShoppingCart(productList) {  return Object.freeze({
someOtherMethod,
...productList
)}
function someOtherMethod () {
// code
}
}

Since all fields are just past directly into Object.freeze().

Cheers!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Dana Woodman
Dana Woodman

Written by Dana Woodman

πŸ‘¨πŸ»β€πŸ’» Software Hacker πŸ‘¨πŸ»β€πŸ­ Maker πŸ›© Travel Junkie πŸ•. Outdoors Enthusiast

Responses (2)

Write a response