0

I need to create an array from all of the values in an emum. This seems to work:

enum Foo {
  one = 'one',
  two = 'two',
  three = 'three',
}

console.log(Object.values(Foo));

However will the order always be one, two, three? It seems to be this way when I test but as Foo is an object in JavaScript I don't know if this can be relied upon?

Evanss
  • 23,390
  • 94
  • 282
  • 505
  • Also relevant: [Does ES6 introduce a well-defined order of enumeration for object properties?](https://stackoverflow.com/q/30076219) and [How do the different enum variants work in TypeScript?](https://stackoverflow.com/q/28818849) – VLAZ Nov 26 '21 at 12:59
  • It might be helpful to explain why order matters here. – jonrsharpe Nov 26 '21 at 13:11

0 Answers0