We have answer of your question!

100% solved queries, no empty question

Question: Search a named array in javascript


0

This might be a duplicate but I could not help but post this, I have an array with this format

answerCollection= {
0:
{selected : a,
 status :  false   
 },
1:
{selected : a,
 status :  false   
 }
}

I want to do an index check on the this aray like this

if(answerCollection.indexOf(indexNo) == -1){
 sel = "a";
 }

but it keeps failing i.e. I keep getting a return value of -1, irrespectively of if the index exist in the array or not.

How do I do this kind of search?

Question author Kolexinfos | Source

Answer


1


if(answerCollection[indexNo] == null){
 sel = "a";
}

for example look here.

Answer author Whyme

Tickanswer.com is providing the only single recommended solution of the question Search a named array in javascript under the categories i.e javascript , . Our team of experts filter the best solution for you.

Related Search Queries:

javascript find object in array by property value , javascript find index of object in array , angular find object in array , javascript find index of object in array by property , javascript find string in array , javascript array find , array.filter in javascript ,


You may also add your answer

Thanks for contributing an answer to Tick Answer!