1 Moment of Time: Silentville. Silentville. 271724. Jul 25, 2015. Прохождение трех секунд в 1 минуту в Сайлентвилле.
Category:Hidden object games
Category:Adventures
Category:2008 video games
Category:Video games developed in Ukraine
Category:Windows games
Category:Windows-only gamesQ:
Accessing an enumeration value via a key
I'm trying to create an enumeration of values that I can access like so:
enum myEnum {
kFirst = 'first',
kSecond ='second'
}
let obj = {
myEnum: {
'second': 1
}
}
I want to be able to look up myEnum using a key. For example:
let myKey ='second'
let value = obj.myEnum[myKey]
But this returns:
{
myEnum:'second',
value: 1
}
Instead of:
{
myEnum:'second',
value: 1
}
I have looked through the docs but I can't find anything that explains this.
A:
You're already defining your enum as an object, so there's no reason to create another type.
let obj = {
myEnum: {
'second': 1
}
};
let myKey ='second';
let value = obj[myKey];
console.log(value);
If you don't want to create an object, then use an array:
let obj = ['first','second'];
let myKey ='second';
let value = obj.find(function(value) {
return value === myKey;
});
console.log(value);
Video of kangaroo escaping free fall with a bungee cord - jonathansizz
http ac619d1d87
Related links:
Comments