Thursday, 19 September 2013

Search through multidimentional array JavaScript

Search through multidimentional array JavaScript

I got stuck trying to retrive array items. So here is the deal. I have a
two dimentional array which has value and key so example of my data is:
[
Object { css="SS", title="Apple"},
Object { css="SS", title="Orange"},
Object { css="SS", title="Banana"}
]
I want to see if an object exists in the array above. And I have no idea
why its not working, here is my code to find the object:
jQuery.inArray("Apple", fruits["title"]); //this returns -1 why?
Any ideas how to search two dimentional array?

No comments:

Post a Comment