Do Numeric Enum in TypeScript Start From 0 or 1?

Numeric enum in TypeScript start with 0 by default. This means that if the first member in the enum has no initializer, it is assigned the value 0; all members that follow are auto-incremented from that point on.

For example:

enum FooNum {
    A,
    B,
    C,
}

console.log(FooNum.A); // 0
console.log(FooNum.B); // 1
console.log(FooNum.C); // 2

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.