Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:14:55+00:00 2026-06-13T17:14:55+00:00

I have a value, and an array. I’m trying to see if the value

  • 0

I have a value, and an array. I’m trying to see if the value is contained within the array. I’m using jQuery’s ‘inArray’ method but the results keep telling me that it is not found.
What am I doing wrong?

here is the fiddle.
http://jsfiddle.net/p9xcb/

var array =  ["79C8A605-1384-4A51-8AC9-C53C1AE075D2", "E367CEEE-A344-4C63-B4B3-A1CC20D3DAF2", "1E3ED40E-935A-4895-960E-89FFD8CD81B9", "2E67F9E8-4770-497E-A938-0A145DA033AF", "35B33B09-6BD3-495E-9A3E-4B5D6DF8655E", "F419FB1F-4922-46B9-B651-8BB0D42510DD", "61FD263B-175E-4434-8A88-8E00418E2E14", null, "FF98229A-998C-49AD-9392-E4CE98115C0A", "C88B9D52-FE70-430C-B43D-D52F9B22E997", "1DDF2413-B453-42BB-8D78-7A7AAA94C353", "55D922B1-EBCD-4EC3-87A5-FA6AA38C9975", "0FA8079A-F76F-4CA5-B370-7B8B9AF2720A", "CF1971EF-E0C2-4C54-8131-A19FB14F2515", "A736854B-73A2-4282-85E0-6298D8AB815A", "DA280665-DC5E-4DF2-9FB1-924E1C8E4713", "9C73A934-9DDF-415C-A409-F2AC79493539", "FD950617-2C9C-4B6C-94F1-6C746699B636", "F184BBBE-C296-4F1D-9DD7-57F87D3B95A6", "676955FB-3F3D-4DC6-8F9D-A873A8440499", "5509E5C6-6650-4DF6-B7A9-49C8BC935B53", "7D88DCD6-431E-41EB-9A87-5C19C2D579FC", "509EA3D8-5B30-41F0-809B-D1E45BC30E3C", "6C4D6F4F-A188-4E6C-B40C-02AE4A5FFAAB", "710E2593-FE14-4CAB-B97C-95D96BB81266", "CBEB793E-A572-4995-8342-E9A48EF19E82", "A8C937F2-056C-46B4-8034-11CA4BB37A1D", "8E9B5E53-298B-4BDE-A696-20F102C28F12", "7BF7421C-CB21-4A44-BBA3-2CFD3A74C889", "F8D89224-7BB7-477F-BB8E-F5B2633A4111", "73F196CF-62F8-4F7A-9938-4F52404450E4", "B4D419D6-A5B8-4141-8C0E-ADCBEC72F2D8", "59ECF672-5C93-4E1E-8E30-6E0699874D61", "EC72A684-5888-48E1-99FD-FE455A50222F", "5D234D6D-E296-4D90-B87E-61FB6FB48702", "8EDD5718-E28A-4A4E-85BA-4DC9C072EAA8", "66FEA812-9945-4FFB-87CB-CCA828768FA0", "0025CB40-3016-4286-AD60-46685EDFD6A1", "508AC4D3-EA29-43A9-92CC-453FE2438D58", "030C5CBE-C227-4326-BED7-DB16A90D5A36", "2AAFF154-0FD0-4B60-9180-DE19A9E0890B", "64EBB0B4-81C1-46EB-8B1A-711A06E45FA3", "E1AA77B2-0E67-42A7-B7D7-A15D2A4EA448", "E9543440-E66E-4984-AC4E-091F161D33D6", "D93988D5-73D9-4988-B1A1-B48282F3C7B7", "6DC572B8-1F69-4A5C-81C7-6EAC617EBEE1", "BB56B36C-1D90-4B8D-ABF0-4ECD4052DCC1", "D1FEFB8D-84F4-4500-92F2-70FEE23F4B6E", "3A836ED4-639C-42C4-B945-375DC053FB61", "33672786-E964-4C3F-A3EB-7BF6634D13A0", "7F76C892-AEC1-4901-80BE-B93DFF59D159", "0E92F1AD-5C09-4B3D-BAF5-5D62BA3440EF", "73E50616-DCA7-4E83-B81F-100C21A18C49", "CF89704A-BD58-4D41-A5B5-10BAFC6F8085", "0D5CBF2A-3699-4968-A2DC-F6EA61D6C7C1", "FED50D50-86E8-42E2-8CD4-17DC01BB966C", "81EEFFA0-D172-4BC3-8474-2C55E6CB06CA", "8FA6CBBD-D5AC-431D-B1E3-C0D1BA48ECCA", "7EEA9381-F0F0-4252-BF29-D15A5A0283C6", "0FFDE30B-E4C3-40CC-A292-566D54D05821", "E24EE39E-0FDE-4C20-B61C-E5C07B483CF8", "82F6B86F-6EAB-42B4-B19D-CA6EAFF83A92", "7B663073-6296-4A08-89AF-7051EAFC3E8A", "EA36E8B5-A266-473C-A076-96A605A856B9", "4A99A5A0-FBF3-4AC6-A34A-52E761B98C8A", "26513617-D98B-44D9-BDD5-2FFCB8C7783B", "67F93D0F-E145-4447-A7B8-E3D1E944B88C", "9798FD1D-B781-4420-A37E-622E04E69672", "1A872624-E81B-45B7-B6FD-ED229AE54042", "092C0992-FAED-4E74-AB3E-6553F5261EF2", "76B94E6B-BE6B-43F2-ABBD-67A3B92C33B9", "AADF1B4D-F32E-4C0C-B4FC-EAC051338B8C", "E8A2479D-B1FC-4B67-AC94-C1AB8E1C7298", "8F7350C0-867D-461A-92D9-225CF8E91D60", "E742D55B-ADF0-4ADF-A3C9-EC4B3BAA832A", "320EBB4F-F0AB-47E7-A5B6-334429F8DEC8", "CEF5D66B-5EF2-468B-A9BE-06B0BC05E917", "CC6D2205-EB58-414D-A404-ED7B743E385E", "7D7EB4D0-BE31-4F28-928D-8E1FC5C947F0"];

var value = "CC6D2205-EB58-414D-A404-ED7B743E385E";

$('body').html($.inArray(value, array));​

Edit:

If I run this code

if ($.inArray(value, array)) {/*this will never be called, why?*/} 

I will never see anything where /*this will never be called, why?*/ section is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:14:56+00:00Added an answer on June 13, 2026 at 5:14 pm

    You should first understand the concept of truthyness/falseyness in javascript. The following values will evaluate inside a boolean operator as false

    undefined
    null
    empty string
    false
    0
    

    And the following will evaluate true

    non-null object reference
    non-empty string
    true
    any non-zero number
    

    Now do you see the problem using

    if($.inArray(value,array)){
    
    }
    

    Hint: Not finding the element (-1) will evaluate true, finding the element in the first position (0) will evaluate false. Finding the value in any element after the 1st will evaluate true.

    The easy fix is to use:

    if ($.inArray(value, array) >= 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have class method which returns an associative array with a single value in
Possible Duplicate: php sort array by sub-value I have a multidimensional array like the
I have a List with array of object values. I have to display value
I have an array with some value like this: [Organization_id] => Array ( [0]
I have an Array to hold the value from DB. If I try with
I have to compare a value in a string array to that of a
I have an array that I want to sort based on the value of
I have an array where I want to get the next value. $sorting =
Say I have an array of key/value pairs in PHP: array( 'foo' => 'bar',
i have an array which could look like this: $config[$name][$array]['key'] = 'value'; // here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.