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

164
Views
¿Cuál es la diferencia entre crear una matriz doble con la matriz de JavaScript y funciones de relleno?

Creé una matriz usando las funciones from y fill de Array. Sin embargo, cada matriz creada por los dos métodos hizo que el resultado de procesamiento deseado fuera diferente.

Verifique el contenido de la pregunta en el siguiente código: ¿Por qué el resultado final es diferente?

 let a1 = Array.from(Array(5), () => []); let a2 = Array(5).fill([]); // both '[ [], [], [], [], [] ]' console.log(a1); console.log(a2); // both '[]' console.log(a1[0]); console.log(a2[0]); a1[0].push(1); a2[0].push(1); // but the result isbut console.log(a1); // [ [ 1 ], [], [], [], [] ] // I wanted results like this for both a1 and a2. console.log(a2); // [ [ 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1 ] ]
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!