Answers for "Typescript loop over enum"

2

typescript iterate over enum

for (const key in EnumObject) {
  console.log(key, EnumObject[key]);
}
Posted by: Guest on September-19-2020
0

Typescript loop over enum

function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O): K[] {
    return Object.keys(obj).filter(k => Number.isNaN(+k)) as K[];
}
Posted by: Guest on June-10-2021

Browse Popular Code Answers by Language