mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-13 21:02:08 +08:00
Update ES6 array destructuring (#31017)
This commit is contained in:
parent
c2e6329296
commit
d6fa57cd2f
@ -32,6 +32,15 @@ console.log(firstName, lastName); // John Smith
|
||||
|
||||
The examples above show the benefit of using the ES6 Destructuring Assignment.
|
||||
|
||||
You can skip some values by putting comma
|
||||
|
||||
```javascript
|
||||
const address = ['Rue Cler', 'Paris', 'France'];
|
||||
const [street, , country] = address;
|
||||
or
|
||||
const [street] = address;
|
||||
```
|
||||
|
||||
You can also use Destructuring on objects using a similar syntax
|
||||
|
||||
```js
|
||||
|
||||
Loading…
Reference in New Issue
Block a user