JSFiddle - React, Tailwind, and code Playground

by faridkiron

TypeScript

enum Colors {
        RED = "RED COLOR" as any,
        BLUE = "BLUE COLOR" as any,
        GREEN = "GREEN COLOR" as any
    }
    
    let enumKey = Colors["BLUE COLOR"];
    console.log(enumKey);

// Another Example 
    
  enum Colors {
  RED = <any>"RED COLOR",
  BLUE = <any>"BLUE COLOR",
  GREEN = <any>"GREEN COLOR"
}

let colorValue = Object.keys(Colors)[Object.values(Colors).indexOf("RED COLOR")];

console.log(colorValue);