committed by
Oliver Eyton-Williams
parent
38badd6259
commit
4507a6b254
@ -26,7 +26,7 @@ const profileUpdate = ({ name, age, nationality, location }) => {
|
||||
```
|
||||
|
||||
This removes some extra lines and makes our code look neat.
|
||||
This has the added benefit of not having to manipulate an entire object in a function; only the fields that are needed are copied inside the function.
|
||||
This has the added benefit of not having to manipulate an entire object in a function — only the fields that are needed are copied inside the function.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
|
@ -7,7 +7,7 @@ localeTitle: Utilice la asignación de destrucción para pasar un objeto como pa
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> En algunos casos, puede destruir el objeto en un argumento de función. Considere el siguiente código: <blockquote> const profileUpdate = (profileData) => { <br> const {nombre, edad, nacionalidad, ubicación} = profileData; <br> // haz algo con estas variables <br> } </blockquote> Esto destruye efectivamente el objeto enviado a la función. Esto también se puede hacer en el lugar: <blockquote> const profileUpdate = ({nombre, edad, nacionalidad, ubicación}) => { <br> / * hacer algo con estos campos * / <br> } </blockquote> Esto elimina algunas líneas adicionales y hace que nuestro código se vea limpio. Esto tiene la ventaja adicional de no tener que manipular un objeto completo en una función; solo los campos que son necesarios se copian dentro de la función. </section>
|
||||
<section id="description"> En algunos casos, puede destruir el objeto en un argumento de función. Considere el siguiente código: <blockquote> const profileUpdate = (profileData) => { <br> const {nombre, edad, nacionalidad, ubicación} = profileData; <br> // haz algo con estas variables <br> } </blockquote> Esto destruye efectivamente el objeto enviado a la función. Esto también se puede hacer en el lugar: <blockquote> const profileUpdate = ({nombre, edad, nacionalidad, ubicación}) => { <br> / * hacer algo con estos campos * / <br> } </blockquote> Esto elimina algunas líneas adicionales y hace que nuestro código se vea limpio. Esto tiene la ventaja adicional de no tener que manipular un objeto completo en una función — solo los campos que son necesarios se copian dentro de la función. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> Use la asignación de desestructuración dentro del argumento de la función <code>half</code> para enviar solo <code>max</code> y <code>min</code> dentro de la función. </section>
|
||||
|
@ -6,7 +6,7 @@ title: Use Destructuring Assignment to Pass an Object as a Function's Parameters
|
||||
---
|
||||
## Problem Explanation
|
||||
|
||||
You could pass the entire object, and then pick the specific attributes you want by using the `.` operator. But ES6 offers a more elegant option!
|
||||
You could pass the entire object and then pick the specific attributes you want by using the `.` operator, but ES6 offers a more elegant option!
|
||||
|
||||
|
||||
---
|
||||
@ -14,7 +14,7 @@ You could pass the entire object, and then pick the specific attributes you want
|
||||
|
||||
### Hint 1
|
||||
|
||||
Get rid of the `stats`, and see if you can destructure it. We need the `max` and `min` of `stats`.
|
||||
Get rid of the `stats` and see if you can destructure it. We need the `max` and `min` of `stats`.
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user