I know that this is not the place to post my question but here it is. If someone knows a better place please do inform.
I have an array of objects and I want to retrieve specific elements that match certain criteria, i.e. find value A in an object B. The problem is that I cannot know what is A (text, object, reg exp, array) and what is B (text, object, array). Also, I must assume that B may be an array or a key/value object and that A may be anywhere (including 'children' objects). This is usually the case when I have a JSON response from an external source and want to find something in there but without hard-coding any specific methods or search cases. I think the best way to achieve this is to have a method loop through the objects and arrays that are passed (and found) and call it self until there only two string/number/regexp values to be compared against. What I've done up to now is here http://jsbin.com/ahezi/edit - if you haven't understood what I just said perhaps the example on this page will help. Even tho it works as expected it is quite slow and I have no idea where the problem is. So my question is this: Is there a better way to achieve this result, and if not, how can I make the Find function faster?