1

I have this enum:

enum defaultShaderType {
  VERTEX_SHADER = 23,
  FRAGMENT_SHADER = 57
}

Is there a direct way to access the numeric values by ordinal index of an enum in typescript? What I want is for example:

const value1 = defaultShaderType[0]; //23
const value2 = defaultShaderType[1]; //57

When I try it that I obtain undefined. In my case I want the values in a for loop, so I would like to get the values for the number of elements in the enum. I know there are many workarounds and that can achieve that with other data structures, but can a typescript enum be used this way?

Thanks in advance.

rustyBucketBay
  • 4,320
  • 3
  • 17
  • 47

0 Answers0