In React, I use this kind of syntax often for conditional rendering:
const exampleState = 1;
const retval = {
0: "Value for state 0",
1: "Value for state 1",
2: "Value for state 2",
}[exampleState]
// this returns "Value for state 1"
What is this syntax called?
Edit: added const retval
to make it actually valid code