I like how easy it is to work with lists:
var numberName = ["zero", "one", "two", "three", "four"][number];
And hashes:
var numberValue = {"zero":0, "one":1, "two":2, "three":3, "four":4}[numberName];
In most other languages, this will be pretty heavy code. The defaults are also fine. For example, a code error message:
var errorDesc = {301: "Moved Permanently", 404: "Resource not found", 503: "Server down" }[errorNo] || "An unknown error has occurred";
manixrock Mar 10 2018-11-11T00 : 00Z
source share