Bird
0
0

What will be the value of Color.Green in this enum?

easy📝 Syntax Q3 of 15
Angular - TypeScript in Angular
What will be the value of Color.Green in this enum?
enum Color { Red = 1, Green, Blue }
A1
B2
C3
D0
Step-by-Step Solution
Solution:
  1. Step 1: Understand enum auto-increment

    When the first value is set to 1, the next values auto-increment by 1.
  2. Step 2: Calculate Green's value

    Red = 1, so Green = 2, Blue = 3.
  3. Final Answer:

    2 -> Option B
  4. Quick Check:

    Enum auto-increment = Next value +1 [OK]
Quick Trick: Enum values auto-increment from first assigned number [OK]
Common Mistakes:
  • Assuming all start at 0
  • Forgetting auto-increment
  • Confusing value assignments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes