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

195
Views
Cómo usar jQuery.map() en una matriz de objetos para devolver una matriz de matrices

Me gustaría usar jQuery para convertir una matriz de objetos en una matriz de matrices usando el mapa.

Por ejemplo si tengo esto:

 var ObjArr = [{ a:1,b:2 },{ a:2,b:3 },{ a:3,b:4 }]; var ArrArr = $.map(ObjArr, function(n,i){ return [ na, nb ]; });

De modo que el resultado sería:

 ArrArr = [[1,2],[2,3],[3,4]]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Con los jQuery.map() (docs) y map() (docs) necesita ajustar dos veces el valor devuelto:

 var ArrArr = $.map(ObjArr, function(n,i){ return [[ na, nb ]]; });

... de lo contrario, por alguna razón, concatena la matriz que se devuelve. De esta manera, concatena la matriz externa y coloca el contenido (la matriz interna) en el siguiente índice.

over 4 years ago · Santiago Trujillo 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!