Another way is to create a plain JavaScript object from an array using .reduce() which allows you to define each string only once.
constLIGHT_SWITCH_EVENT=['TOGGLE','SOME_OTHER_EVENT',].reduce((obj,item)=>{obj[item]=item;returnobj;},{});// then use it like this: LIGHT_SWITCH_EVENT.TOGGLE
I'll stick to enums as I think they are much easier to read.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Another way is to create a plain JavaScript object from an array using
.reduce()
which allows you to define each string only once.I'll stick to enums as I think they are much easier to read.