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

232
Views
¿Cómo asignar clave a cada elemento o valor en una matriz en javascript?

Tengo una matriz como esta:

 [link1,link2,link3]

Pero lo quiero así:

 [uri:link1,uri:link2,uri:link3]

Por favor guíame sobre esto. Gracias.

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

0

tal vez podría intentar mapear su matriz y devolver una nueva matriz de objetos como este

 const array1 = [1, 2, 3, 4]; const newArr = array1.map(i => {return {uri: i}}) console.log(newArr); // > Array [Object { uri: 1 }, Object { uri: 2 }, Object { uri: 3 }, Object { uri: 4 }]
about 4 years ago · Juan Pablo Isaza Report

0

Si necesita en forma de (matriz de objetos)

 var test = ['a', 'b', 'c', 'd']; function setID(item, index) { var fullname = {"id: ": item}; return fullname; } var output = test.map(setID); console.log(output);

salida: [ { "id: ": "a" }, { "id: ": "b" }, { "id: ": "c" }, { "id: ": "d" } ]

about 4 years ago · Juan Pablo Isaza Report

0

Utilice Array.from! Es realmente simple y rápido.

 var test = ['a', 'b', 'c', 'd']; var newTest = Array.from(test, val => 'id: '+ val); console.log(newTest);

salida: [ "id: a", "id: b", "id: c", "id: d" ]

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!