How to convert Javascript object to Array?
I have an object as below,
const data = {a: 10, b:20}
I want to convert it to an array, like ["a", "b"].
How to do that?
1 Answer
5 years ago by Divya
To get the key values from an object and convert them to an array, you can use the keys() method
const a = Objects.keys(data);
console.log(a);
// ["a", "b"]
5 years ago by Divya