-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
  • 59,490
  • 13
  • 101
  • 110
user12763413
  • 1,177
  • 3
  • 18
  • 53

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
  • 10,098
  • 4
  • 18
  • 39