Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
¿Por qué necesito paréntesis alrededor de la asignación de desestructuración?

Supongamos que tengo esta función:

 const testFunction = () => { const item_one = 1 const item_two = 2 return { item_one, item_two } }

Cuando estoy desestructurando el valor de retorno de esta función como esta

 let item_one, item_two; // the variables are defined elsewhere { item_one, item_two } = testFunction() // <-- Syntax error: Unexpected token "="

Recibo un error de sintaxis.

En cambio, cuando estoy haciendo

1)

 let { item_one, item_two } = testFunction() // not suitable since I need to reassign

o

2)

 let item_one, item_two; ({ item_one, item_two } = testFunction())

el código se ejecuta como se esperaba.

¿Alguien podría explicar por qué necesito los paréntesis alrededor de la tarea en 2. y por qué recibo un error de sintaxis?

¡Gracias!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!