Re: If value is in a list
- From: "Paul Lautman" <paul.lautman@xxxxxxxxxxxxxx>
- Date: Tue, 22 Apr 2008 20:59:31 +0100
Mike wrote:
What about alert(num in list);- Hide quoted text -
Yes, that would work, but I'm actually concerned about the isInList
function. I imagine there's some way to avoid the whole for(i in
list) routine. For example, is there a way to do this:
function isInList( number, list ) {
if(number == anyElementIn( list ) { return true } else { return
false }
}
is there some built in javascript method that will check a value
against any value in an Array?
Thanks!
Mike
(','+list.toString()+',').indexOf(','+num+',')
If IE had implemeneted it properly you'd only need list.indexOf(num)
.
- Follow-Ups:
- Re: If value is in a list
- From: Thomas 'PointedEars' Lahn
- Re: If value is in a list
- From: Thomas 'PointedEars' Lahn
- Re: If value is in a list
- From: Tom Cole
- Re: If value is in a list
- References:
- If value is in a list
- From: Mike
- Re: If value is in a list
- From: Tom Cole
- Re: If value is in a list
- From: Mike
- If value is in a list
- Prev by Date: Re: If value is in a list
- Next by Date: Re: Safari 3 and refresh
- Previous by thread: Re: If value is in a list
- Next by thread: Re: If value is in a list
- Index(es):
Relevant Pages
|