What is a const enum in TypeScript and how does it differ from a regular enum?

TypeScript Associate Hard

TypeScript Associate — Hard

What is a const enum in TypeScript and how does it differ from a regular enum?

Key points

  • Const enums have their members inlined as literal values
  • Regular enums generate a JavaScript object at runtime
  • Const enums are erased during compilation
  • Regular enums retain their structure in the generated JavaScript code

Ready to go further?

Related questions