147
rated 0 times
[
153]
[
6]
/ answers: 1 / hits: 16835
/ 6 Years ago, tue, january 16, 2018, 12:00:00
I have the following TypeScript enum:
enum Country {
BR = Brazil,
NO = Norway
}
Then imagine I have a method that takes a Country
as an argument, like so:
someFunc = (country: Country): void => {
console.log(country) //Will print Brazil if country = Country.BR
console.log(Country[country]) //Same as above
console.log(???) //I want to print BR if country = Country.BR
}
How do I solve the third console.log
statement?
How do I get a hold of the enum key?
Regards
More From » reactjs