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

84
Views
Obtener valor por clave de una matriz de matriz - Javascript

Tengo un meta como el siguiente:

 obj = { meta: [['type', 'test1'], ['key2', 'value2']], value: 'text1', }

Quiere leer la prueba de valor pasando el tipo de clave

el resultado esperado es test1

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

0

Podrías usar Object.fromEntries()

 const obj = { meta: [['type', 'test'], ['key2', 'value2']], value: 'text1', } const key = 'type' const res = Object.fromEntries(obj.meta)[key]; console.log(res)

about 4 years ago · Juan Pablo Isaza Report

0

Debe reestructurar meta como un objeto en lugar de una matriz de pares como:

 obj = { meta: { 'type': 'test', 'key2': 'value2' } value: 'text1', }

Ahora, puede acceder a lo que necesita como obj['meta']['type'] u obj.meta.type .

about 4 years ago · Juan Pablo Isaza Report

0

obj = { meta: [['type', 'test'], ['key2', 'value2']], value: 'text1', } for(let arr of obj.meta){ if(arr[0]==='type'){ return arr[1]; } }

o

 const res=obj.meta.find(arr=>arr[0]==="type"); if(res && res.length) return res[1]

Tenga en cuenta que este código devuelve solo el primer "tipo". Si tiene "tipo" dos veces, obtendrá el primer resultado.

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!