typescript in enum iterable code example
Example 1: typescript iterate over enum
for (const key in EnumObject) {
console.log(key, EnumObject[key]);
}
Example 2: typescript enum to array
// Helper
const StringIsNumber = value => isNaN(Number(value)) === false;
// Turn enum into array
function ToArray(enumme) {
return Object.keys(enumme)
.filter(StringIsNumber)
.map(key => enumme[key]);
}