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

366
Views
El literal del objeto del mapa de Javascript no funciona, pero el nuevo Object () funciona

¿La notación literal de objeto no funciona dentro de la función de mapa? Intenté esto en Node 12 y 15 REPL

 > nums = [1,2,3,4] [ 1, 2, 3, 4 ] > nums.map(n => { n }) [ undefined, undefined, undefined, undefined ] > nums.map(n => new Object({n})) [ { n: 1 }, { n: 2 }, { n: 3 }, { n: 4 } ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba esto:

 nums.map(n => ({ n }))

Sin los paréntesis, { n } se interpreta como el cuerpo de su función. Al incluir paréntesis, está indicando que { n } debe devolverse implícitamente en su lugar.

Aquí hay una descripción general de los rendimientos implícitos frente a los explícitos, que debería ayudar a proporcionar más detalles.

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!