how to get both key and value of enum in typescript

Solutions on MaxInterview for how to get both key and value of enum in typescript by the best coders in the world

showing results for - "how to get both key and value of enum in typescript"
Marta
06 Oct 2020
1var enumNames=[];
2for (var log in LogEntry) {
3    if (isNaN(Number(log))) {
4       enumNames.push(log);
5   }    
6}
7console.log(enumNames);
8
9//Output
10//["ERROR", "WARN", "INFO", "DEBUG"]
11
Cassiopeia
09 Oct 2017
1var enumValues=[];
2for (var log in LogEntry) {
3    if (!isNaN(Number(log))) {
4       enumValues.push(log);
5   }    
6}
7console.log(enumValues);
8
9//Output
10//["0", "1", "2", "3"]
11