Checking defined item in enum
This question already has an answer here:
In this special case, you could access the property and if the result is falsey, then take the default property 99
.
const getAttributes = id => uiElementAttributes[id] || uiElementAttributes[99];
Otherwise, you could use the in
operator, or the suggested Object#hasOwnProperty
.
上一篇: 检查是否已分配toString
下一篇: 在枚举中检查定义的项目