'switch' operator improvement

liorean liorean at gmail.com
Tue Oct 16 11:11:15 PDT 2007

On 16/10/2007, Peter Hall <peter.hall at memorphic.com> wrote:
> already you can do something like this:
> var str;
> switch(true){
> case /a/.test(str):
>   alert('a');
>   break;
> case /b/.test(str):
>   alert('b');
>   break;
> }

I can only imagine that solution being preferable to chained
if..else-statements in one case, and that would be if you actually
used the fall through mechanism. If you don't fall through, it's just
bloat without any gain.
David "liorean" Andersson

More information about the Es4-discuss mailing list