TypeScript Enum
Enumeration (Enum) is a data type in typescript. that are used to store constant element value. There is three type of Enum will possible in typescript.
Numeric Enum
enum Month{
January,
February,
March,
April,
May,
June
};

enum Wallet{
coins = 10,
rupee = 100,
dollar = 3,
euro = 12
};

String Enum
enum Month{
Jan="January",
Feb="February",
Mar="March",
Apr="April",
May="May",
June="June"
};
console.log(Month);

{ Jan: 'January',
Feb: 'February',
Mar: 'March',
Apr: 'April',
May: 'May',
June: 'June' }
Heterogeneous Enum
enum Code{
error = 0,
status,
type = "Typescript"
};
console.log(Code);

{ '0': 'error',
'1': 'status',
error: 0,
status: 1,
type: 'Typescript' }
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment