how to get both key and value of enum in typescript how to get both key and value of enum in typescript

The solution for “how to get both key and value of enum in typescript how to get both key and value of enum in typescript” can be found here. The following code will assist you in solving the problem.

var enumValues=[];
for (var log in LogEntry) {
if (!isNaN(Number(log))) {
enumValues.push(log);
}
}
console.log(enumValues);

//Output
//[“0”, “1”, “2”, “3”]
var enumNames=[];
for (var log in LogEntry) {
if (isNaN(Number(log))) {
enumNames.push(log);
}
}
console.log(enumNames);

//Output
//[“ERROR”, “WARN”, “INFO”, “DEBUG”]

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in