Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's an interesting point about using number values- I have to say I've never needed to do a bitwise operation in JavaScript, though I know some high-performance projects like physics engines and the TypeScript compiler itself use them

Still, I'd prefer:

  const MyNumericEnum = {
    One: 0b001,
    Two: 0b010,
    Three: 0b100
  } as const

  type MyNumericEnum = typeof MyNumericEnum[keyof typeof MyNumericEnum]
Just for explicitness. But that's my subjective opinion


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: