Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to find if an element belongs to an array in JS

    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

  • #2
    New Coder
    Join Date
    May 2004
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!")
    }

    }

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #4
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks for your help!

    hi,

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

    Thanks
    Gautam


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •