...

View Full Version : how to find if an element belongs to an array in JS



ganand
06-17-2004, 04:11 AM
Hi,

Is there any way to find out if a particular element exists in an array.. i want to compare an element with the existing elements of the array to find if the element exists in the array ..i mean is there any in built function in javasript that would do the linear search and find if an element is a part of the array.

Thanks
Gautam

guowei1000
06-17-2004, 04:16 AM
u can loop throught the array then store the data in a valuabe

for (i=0; i=loopingarray.length; i++)
{
var something = loopingarray(i)
if (something == compareanythinguwan)
{
alert("omg this doesnt help at all!")
}

}

sad69
06-17-2004, 09:08 PM
This may be of some help:
http://www.embimedia.com/resources/labs/js-inarray.html

Sadiq.

ganand
06-18-2004, 02:30 AM
hi,

Thanks a lot guowei1000 and sadiq.. i could get the work done with ur help..

Thanks
Gautam



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum