typescript enum with description code example
Example 1: 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]);
}
Example 2: enum in ts
enum Direction {
Up,
Down,
Left,
Right,
}
Example 3: enums in typescript
enum Direction {
Up = 1,
Down,
Left,
Right,
}