Just now, I came across this issue while attempting to loop through an enum.
Imagine you have the following:
enum Gender {
Male = 1,
Female = 2
}
If you write:
for (let gender in Gender) {
console.log(gender)
}
You will notice that it iterates over the enum 4 times. Initially displaying the string representations of 1 and 2, followed by printing the strings Male and Female.
I can only assume that this behavior is intentional. But my question remains - what is the rationale behind this somewhat unusual approach?