TypeScript const variable is useful when we want to declare a variable which can not be reassigned.
For example if we declare a variable as:
const id = 14;
then we can not reassign the id variable.So if we try to reassign the id variable we will get compilation error.
id=2;
If we execute the above line then we will get the error
It is necessary to initialize const variables.If const variable is not initialized then compile time error is thrown
Leave a Reply