When dealing with a TypeScript enum like the one shown below:
export enum Color {
Red,
Green,
Blue,
}
I am trying to extract all its values into an array as follows:
["Red", "Green", "Blue"]
However, when I attempt to do so using the code:
const colors = Object.keys(Color);
The resulting array is not what I expected, it includes both index and value entries:
[ '0', '1', '2', 'Red', 'Green', 'Blue' ]
Can someone explain why this is happening and provide a solution to only retrieve the values?