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:
committed by
Randell Dawson
parent
3947a5bf03
commit
44641ab13a
@ -51,7 +51,7 @@ Aún puede lograr el resultado deseado usando la siguiente sintaxis.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const obj = {propertyName: value}
|
const obj = {propertyName: value}
|
||||||
{propertyName: desiredVariableName} = obj
|
const {propertyName: desiredVariableName} = obj
|
||||||
```
|
```
|
||||||
|
|
||||||
Nuestro ejemplo anterior sería reescrito de la siguiente manera:
|
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
|
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]
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user