-3

I am an array of hashes and I want to convert it to array of values something like this

array of hashes [{text: "James"},{text: "developer"}] convert this to array of values ["James", "Developer"]

Please help me achieve this in javascript.

Dan
  • 52,223
  • 13
  • 79
  • 96
user12763413
  • 809
  • 1
  • 12
  • 31

1 Answers1

1

Using Object.values, you can get the values of each object.

const input = [{text: "James"},{text: "developer"}];

const output = input.flatMap((item) => Object.values(item));
console.log(output);
Derek Wang
  • 9,720
  • 4
  • 15
  • 38