Say I have a variable a with the value:
1
Then I have an array b with the values:
[1, 2]
Why does $.inArray(a, b) give me a -1? I should be getting 0, right?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Exactly what you described gives me
0[fiddle]:However, I can replicate your results when I do this (as suggested by IAbstractDownvoteFactory):
.inArrayonly finds matches that are the same type as what you’re searching with (they’re compared with===). If you can’t make your input data the right format, you can do it yourself:To convert
ato a number:To convert all elements of
bto numbers: