Is there a way to extract only the values of an enum and store them in an array? For example, if we have:
enum A {
dog = 1,
cat = 2,
ant = 3
}
Desired output: ["dog", "cat", "ant"]
achieved by:
Object.values(A)
Unfortunately, using this method results in: ["dog", "cat", "ant", 0, 1, 2]
Another issue is that the returned values (0, 1, 2)
don't match the actual values (1, 2, 3)
. How can this be resolved?