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

188
Views
How to get key value in this case {Java Script}

Hi so what iam trying to achieve is basically is simple.Iam try to get only the object key's value from the given array so this is my example array

[{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}] iam expecting a output of something like this [11,12]

where iam getting the data of the aaa key only

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

0

This will do what you want, but the order could well change between different javascript implementations

const input = [{'aaa': '11','text':'hello'},{'bbb': '12','text':'bye'}]

const output = input.map(x => Object.values(x)[0]);

console.log(output)


I note you updated the quesrtion to have both the same first key - if you're looking for aaa value from all elements this is much simpler

const input = [{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}]

const output = input.map(x => x.aaa);

console.log(output)

about 4 years ago · Juan Pablo Isaza Report

0

const o = [{'aaa': '11','text':'hello'},{'aaa': '12','text':'bye'}]

const filtered = o.map(i => +i.aaa)
console.log(filtered)

about 4 years ago · Juan Pablo Isaza Report

0

The JSON path if you convert this into a JavaScript Object Notation format (as JSON).

0.aaa = 11

1.bbb = 12

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!