Recently, I came across a code snippet that is new to me and I'm having trouble finding an explanation for it online:
function segColor(c) {
return {
red: "#FF0000",
green: "#00ff00",
blue: "#0000ff"
}[c];
}
I'm curious about the operation being performed on the function parameter c. Can someone explain what {array}[val] does in JavaScript? My searches for "brackets after braces" haven't turned up much information.