I am encountering an issue with my simple code:
enum Color { BLUE, RED }
class Brush {
color: Color
constructor(values) {
this.color = values.color
}
}
let JSON_RESPONSE = `{"color": "BLUE"}`
let brush = new Brush(JSON.parse(JSON_RESPONSE))
When I try to check the color using:
console.log(brush.color === Color.BLUE)
The output is false
.
I have attempted different variations like
brush.color === Color[Color.BLUE]
However, it resulted in a compiler error.
My question is how can I successfully compare two enums with the syntax enum === enum
?