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

133
Views
¿Es posible asignar parámetros de función a través de la desestructuración?

¿Es posible hacer algo como lo siguiente en js?

 function Something( Point{PointX, PointY} ) { console.log('Point', Point); console.log('PointX,PointY', PointX, PointY); } Something([1,2]);

Si es así, ¿cuál sería la forma correcta de hacerlo?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

function Something(Point) { const [PointX, PointY] = Point console.log('Point', Point) console.log('PointX,PointY', PointX, PointY) }
about 4 years ago · Juan Pablo Isaza Report

0

¿Esto es lo que necesitas?

 function Something([PointX, PointY]) { console.log('PointX,PointY', PointX, PointY); }

Puede desestructurar tanto matrices ( function([x, y] ) como objetos ( function({ x, y }) ).

about 4 years ago · Juan Pablo Isaza Report

0

Claro, pero asegúrese de que las claves coincidan para realizar la asignación de desestructuración de un objeto, como:

 function Something({x,y}) { console.log('PointX, PointY', x, y); } Something({x: 1, y: 2});

En términos de nombrar y también asignarlo al objeto externo, tal vez pueda hacer algo como esto en su lugar:

 function Something(Point) { const {x,y} = Point; console.log('Point, PointX, PointY', Point, x, y); } Something({x: 1, y: 2});

about 4 years ago · Juan Pablo Isaza Report
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!