Re: If value is in a list



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)


.



Relevant Pages

  • Re: If value is in a list
    ... I imagine there's some way to avoid the whole for(i in ... list) routine. ... against any value in an Array? ...
    (comp.lang.javascript)
  • Re: If value is in a list
    ... I imagine there's some way to avoid the whole for(i in ... list) routine. ... function isInArray(value, array) { ...
    (comp.lang.javascript)
  • Re: If value is in a list
    ... list) routine. ... function isInArray(value, array) { ...
    (comp.lang.javascript)
  • companyweb
    ... I cannot imagine what I did to make it go away, and I cannot find any clues ... 1- how to restore the functionality? ... 2- how to avoid this from happening again? ... Mike Ov ...
    (microsoft.public.windows.server.sbs)
  • Re: We are fortunate indeed ...
    ... > clinic and of course we do have a free food box which is filled every ... There are tons of accidents with vehicles full of smuggled> folks; ... I imagine our 100+ degree heat felt pretty good after ...
    (alt.gathering.rainbow)