JQBolo JQBolo - 3 years ago 112
jQuery Question

Jquery Object array accessing in $.each loop

I'm tying to access a specific value in an object array, but ONLY if

a) a specific user ID value is stored in


b) the key

I've been playing around with $.each loops but I'm still sort of confused about accessing values inside nested objects, I'm doing SOMETHING wrong because the value is coming back as undefined no matter how I try to access it, [index].story currently just logs the same array of objects stored in

$.each(response.feed.data, function(key, index){
if([index].id == "USER ID"){


Answer Source

index will store the position of that specific key inside response.feed.data. So you can't access index.story. Instead you will have to access it from key if its present inside key.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download