How to handle JSON's undefined value in a better way? I'm working on Google Book API to post a book's basic information. I notice that some of the books will always miss a value or two under volumeInfo, like this book (Fiddle) that has no publisher value. Do I need to repeat if [object] undefined statement several times for the missing values (e.g Publisher,Average Rating,Rating Count)? Can I do it in a more concise way?  

 $.ajax({

    url: 'http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20json%20WHERE%20url%3D%22https%3A%2F%2Fwww.googleapis.com%2Fbooks%2Fv1%2Fvolumes%3Fq%3Disbn%3A1879505215%22&amp;format=json&amp;diagnostics=true&amp;callback=?',
    dataType: 'json',
    success: function (data) {

 $(data.query.results.json.items).each(function (index, item) {

    var isbn10;

 $.each(item.volumeInfo.industryIdentifiers, function(index, item) {

    if (item.type === "ISBN_10") {
    isbn10 = item.identifier;
    return false;
    }

    });
    var Rating = item.volumeInfo.averageRating;
    var RatingCount = item.volumeInfo.ratingsCount;
    var item_html = '';          

    item_html += '   
        &lt;li&gt;&lt;img src="' +item.volumeInfo.imageLinks.thumbnail+'&lt;/li&gt;
        &lt;li&gt;&lt;span&gt;Author:&lt;/span&gt; ' + item.volumeInfo.authors + '&lt;/li&gt;
        &lt;li&gt;&lt;span&gt;Publisher&lt;/span&gt; ' + item.volumeInfo.publisher + '&lt;/li&gt;
        &lt;li&gt;&lt;span&gt;PublishDate:&lt;/span&gt; '+item.volumeInfo.publishedDate+'&lt;/li&gt;
        &lt;li&gt;&lt;span&gt;Category:&lt;/span&gt; ' + item.volumeInfo.categories + '&lt;/li&gt;
        &lt;li&gt;&lt;span&gt;Page Count:&lt;/span&gt; ' + item.volumeInfo.pageCount +' &lt;/li&gt;
        &lt;li&gt;&lt;span&gt;ISBN:&lt;/span&gt; ISBN10_' + isbn10 +' &lt;/li&gt;
        &lt;li&gt;&lt;span&gt;Description: &lt;/span&gt; ' + item.volumeInfo.description +' &lt;/li&gt;';

    if (Rating != undefined) {
    item_html += '&lt;li&gt;&lt;span&gt;Average Rating:' + Rating +'&lt;/span&gt;&lt;/li&gt;';
    }

    if (RatingCount != undefined) {
    item_html += '&lt;li&gt;&lt;span&gt;Rating Count:' + RatingCount +'&lt;/span&gt;&lt;/li&gt;';
    }

    var title_html ='' +item.volumeInfo.title + '';

    $('#bookhead').append(title_html);

    $('#bookdetail ul').append(item_html);

    });

    },
    error: function () {}

    });
You can define a hash of the possible field names and loop through them:

var fieldTitles = {
    description: "Description",
    Rating: "Average Rating",
    RatingCount: "Rating Count"
};

var volumeInfo = item.volumeInfo;
for (var key in fieldTitles) {
    if (volumeInfo[key]) {
        item_html += '&lt;li&gt;&lt;span&gt;' + fieldTitles[key] + ':' + volumeInfo[key] +'&lt;/span&gt;&lt;/li&gt;';
    }
}


Additional notes:


store item.volumeInfo to a local variable so you don't have to access it through item object all the time.
Most of the time it's better and simpler to check for existence of a value with if (someVar) rather than comparing directly with undefined.