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

208
Views
¿Cómo completo una nueva matriz con n matrices vacías distintas, en una declaración de inicialización concisa de una línea?

Aquí es donde estoy atascado. Quiero tomar esta declaración y revisarla de manera que la matriz vacía que llene (que supongo que podría no funcionar con valores dinámicos), inicialice el depósito en las n matrices vacías distintas.

¿Cómo hago esto? ¿Hay alguna manera de hacer que este método de relleno se comporte de la manera prevista?

 let radix = 10; let badBucket = [...Array(radix).fill([])]; let goodBucket = JSON.parse(JSON.stringify([...Array(radix).fill([])])); badBucket[3].push(33); goodBucket[3].push(33); console.log(JSON.stringify(badBucket)); console.log(JSON.stringify(goodBucket));

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

0

Puede usar la función de devolución de llamada de Array.from .

 let length = 5; let res = Array.from({length}, _=>[]); console.log(res);

about 4 years ago · Juan Pablo Isaza Report

0

Probar:

 let radix = 10; let bucket = [...Array(radix)].map(e=>[]) bucket[0].push(1) console.log(JSON.stringify(bucket));

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!