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
Take an array with just one object and transform to a single array of values

Given the following:

let arr = [
    { name: 'AAA' },
    { name: 'BBB' },
    { name: 'CCC' },
    { name: 'DDD' },
    { name: 'EEE' },
    { name: 'FFF' }
 ];

I'm trying to covert the above to a new array with just the values. I tried:

console.log(Object.values(arr));

but this didn't work.

The end result that I am after is just the values within the one new array, that is:

new_arr = ['AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF'];
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

arr.map(value =>  value.name)
about 4 years ago · Juan Pablo Isaza Report

0

Use array map or each or any other loop iteration. The simple one is given below.

let arr = [
    { name: 'AAA' },
    { name: 'BBB' },
    { name: 'CCC' },
    { name: 'DDD' },
    { name: 'EEE' },
    { name: 'FFF' }
 ];

console.log(arr);

const newarr = arr.map(function(e, i) {
  return e.name
});

console.log(newarr);

about 4 years ago · Juan Pablo Isaza Report

0

Yes, you can try this syntax

let arr = [
{ name: 'AAA' },
{ name: 'BBB' },
{ name: 'CCC' },
{ name: 'DDD' },
{ name: 'EEE' },
{ name: 'FFF' }
];

let array = arr.map((e)=>Object.values(e)[0])

console.log(array);
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!