destructuring an array in ES6 rest (#19426)

* destructuring an array in ES6 rest

* fix: removed extra space in each code line
This commit is contained in:
Ragunathan Maniraj
2018-10-16 09:18:45 +05:30
committed by Randell Dawson
parent 3947a5bf03
commit 44641ab13a

View File

@ -51,7 +51,7 @@ Aún puede lograr el resultado deseado usando la siguiente sintaxis.
```js
const obj = {propertyName: value}
{propertyName: desiredVariableName} = obj
const {propertyName: desiredVariableName} = obj
```
Nuestro ejemplo anterior sería reescrito de la siguiente manera:
@ -63,3 +63,10 @@ const fullName = { first: "John", last: "Smith"};
console.log(firstName, lastName); // John Smith
```
**Desestructuración de matrices con descanso.**
Al desestructurar una matriz, puede descomprimir y asignar la parte restante a una variable usando el patrón de descanso:
```js
const [a, ...b] = [1, 2, 3];
console.log(a); // 1
console.log(b); // [2, 3]
```