Comment
Comment by TAForObvReasons
You can switch on arbitrary types in JS and you can add expressions:
The optimizer will have to be persuaded that the switch and each case is integral before optimizing with a jump table. On the other hand, Arrays typically have a fast path for integer indices.