Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: searching a list of values


Message #1 by bmcelhany@h... on Thu, 15 Nov 2001 00:57:34
I don't know of any js equivalent, but I can't see that you need a lot of 
nested ifs, surely its just shorthand for:
if (x==val1 || x==val2 || x==val3...)
  do something
else
  do something else

Phil
> Hi,
>    VBScript has a function in which you can check to see if a variable 
> appears in a pre-set list of values:
> 
> if x in (val1, val2, val3...) then
>    do something
> else 
>    do something else
> 
> It saves a lot of ugly nested if-then-else statements. Is there an 
> equivelent statement in JavaScript? Thanks!
> 
> Brian

  Return to Index