'switch' operator improvement

Lars T Hansen lth at acm.org
Tue Oct 16 06:00:33 PDT 2007


Neat, though it breaks backward compatibility -- each regexp is
converted to string before the comparison, IIRC.  (Compatibility may
not be a big problem in practice in this case.)

--lars

On 10/16/07, Eugen.Konkov at aldec.com <Eugen.Konkov at aldec.com> wrote:
>
>
> allow RegEx in case
>
> var str= 'a';
> switch( str ) {
>   case /a/:
>     alert('a');
>     break;
>
>   case /b/:
>     alert('b');
>     break;
>   }
>
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>
>



More information about the Es4-discuss mailing list