Heterogeneous enums
📖 Scenario: You are creating a simple program to represent different types of user roles in a system. Some roles are identified by numbers, and others by strings. This mix is called a heterogeneous enum.
🎯 Goal: Build a TypeScript heterogeneous enum called UserRole with both numeric and string values, then print one of the roles.
📋 What You'll Learn
Create a heterogeneous enum called
UserRoleInclude numeric and string values in the enum
Print the value of
UserRole.Admin💡 Why This Matters
🌍 Real World
Heterogeneous enums are useful when you need to represent a set of related constants that have different types, like numeric IDs and string codes, in a clear and organized way.
💼 Career
Understanding enums helps in writing clean, maintainable code in TypeScript, which is widely used in web development and many software projects.
Progress0 / 4 steps