I have an enumeration defined like this:
module.exports = {
APP_TYPES: {
TYPE_ONE: { id: 5, name: "Application One name"},
TYPE_TWO: { id: 9, name: "Application Two name"},
TYPE_THREE: { id: 6, name: "Application Three name"}
}
}
I want to be able to reverse lookup the enum based on property values.
lookupById: function(id) {
for (var app in this.APP_TYPES) {
if(this.APP_TYPES.hasOwnProperty(app) && app.id === id) {
return app;
}
}
}
It appears that I cannot access the 'id' property of the enums. How do I refactor this so that I can access the properties defined on the enums?