Skip to content

Commit

Permalink
Correct destructuring example (#272)
Browse files Browse the repository at this point in the history
`{ api, whatever }` from line 342 is not actually destructuring — though both were introduced in ES2015, the name for this syntax is "Shorthand property names":

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015
  • Loading branch information
telegraham authored and timdorr committed Dec 12, 2019
1 parent c6a7015 commit c1b4536
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,13 @@ function fetchUser(id) {
}
```

To pass multiple things, just wrap them in a single object and use
destructuring:
To pass multiple things, just wrap them in a single object.
Using ES2015 shorthand property names can make this more concise.

```js
const api = "http://www.example.com/sandwiches/";
const whatever = 42;

const store = createStore(
reducer,
applyMiddleware(thunk.withExtraArgument({ api, whatever })),
Expand Down

0 comments on commit c1b4536

Please sign in to comment.