What is const enum?
A constant enum expression is a subset of TypeScript expressions that can be fully evaluated at compile time. An expression is a constant enum expression if it is: a literal enum expression (basically a string literal or a numeric literal)
What is the difference between const and enum?
A constant is a language feature which says that the variable won't change value (so the compiler can do optimisations around that knowledge) where an enum is a specific type. Constants can be any data type but an enum is an enum.
What is the main advantage of using const enum over enum in TypeScript?
A const enum is a more optimized version of the regular enum. At compile time, the compiler replaces all references to the enum values with the actual values. There is no generated object in the compiled JavaScript. Because const enum values are inlined, they can't be reverse-mapped or iterated over.
What is the difference between enum and const object in TypeScript?
const enum : Const enums are similar to enums but they get inlined into the code during transpilation, making them more performant. They have the same limitations as enums, so they are not suitable for scenarios where you need to loop through the keys of the enum at runtime.
An enum declares and defines a compile time checked typed. Always use compile time type checking to make sure arguments and variables are given the correct …
Choose enum when you need the flexibility of runtime access, and prefer const enum when compile-time optimization is critical. If your enum-like …
my question is when should I use each, what is the difference between those two syntaxes and Object.freeze() ?