Searching an object with a WHERE like approach?
<p>I have this object structure which comes from a service:</p>

<pre><code>var response ={"results": [
{"name":"peter" , "habits":"smoking" , "imgID":"something_unique"},
{"name":"paul"  , "habits":"drinking" , "imgID":"something_unique"},
{"name":"patrick" , "habits":"gambling" , "imgID":"something_unique"}
]}
</code></pre>

<p>I iterate the object and create divs which are listened to by a click event:</p>

<pre><code>for(var prop in response) {
        if(response.hasOwnProperty(prop))
            {       
this.div.insert(new Element('div', {'className': '' })
.insert('&lt;img id="'+imgID+'" src="/img.jpg" width=70 height=70 /&gt; ')   
                    );
</code></pre>

<p>In my callback, I can access the id from the object spawned event:</p>

<pre><code>function callback (event) { console.log(event.id) ; var compare_ID=event.id }
</code></pre>

<p>However, in my callback, I need to get the array var name for that one particular object that was clicked. So in concept, I am looking to do:</p>

<p>In callback, iterate <code>response</code> object then select the <code>results[i]</code> where it's <code>imgID</code> is <code>== event.id return response</code> object for further access, not just the <em>string</em> name.</p>

<p>Thanks, and like always, all help is appreciated</p>
