Checking if an element exists in json

Viewed 53811

using the following feed:

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=microsoft&include_rts=1&count=10

I am successfully able to loop through this to get the details I want to display on my html page.

However, I need to check if retweeted_status.user.profile_image_url exists, and I am not sure how to do that?

Currently I am looping through the data where data is returned by jquery-ajax:

data[i].retweeted_status.user.profile_image_url

if data[i].retweeted_status.user.profile_image_url does not exist, it does not return null or undefined, I just get the following error:

cannot read property 'user' of undefined

6 Answers
Related