This question already has an answer here:
I've just run into a piece of code I've never seen before, and can't find an explanation anywhere online:
function segColor(c) {
return {
red: "#FF0000",
green: "#00ff00",
blue: "#0000ff"
}[c];
}
What operation is being done to the function parameter c? What does {array}[val] do in javascript? Searching for "brackets after braces" doesn't really reveal a lot.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire