How to test if an array is defined, empty, or null?

How to test if an array is defined, empty, or null?

I am retrieving JSON data via API from third party services. Below is my code:

  1. $.each(data.data, function(i, article) {
  2.     var txtSum = article.summary.toString();
  3.     var txtTitle = article.name;
  4.     var re = new RegExp('\\b(' + searchValue + ')\\b', 'gi');                 
  5.     txtSum = txtSum.replace(re, '<span>$1</span>');                     
  6.     txtTitle = txtTitle.replace(re, '<span>$1</span>');
  7.     output += '<h6>';
  8.     output += '<a href="../kb/article/'+ article.url_hash + '">' + txtTitle  + '</a>';
  9.     if(typeof article.inherited_roles !==  'undefined' &&  article.inherited_roles > 0)
  10.     {
  11.     output += " <img src='../images/Lock-icon.png' />";
  12.     }
  13.     output += '</h6>';
  14.     output += '<p>' + txtSum + '</p>';
  15. });
How do I check if inherited_roles is defined, empty, or null? I've tried to check the field inherited_roles in line #9 but it does not seem to work. The inherited_roles field's JSON value returned by the API is below:

  1. "inherited_roles": [
  2. "55e722df32131cf85008b580",
  3. "56a13f7c32131c7f6831a372",
  4. "56c4cfe091121c0b5b47fe66"
  5. ]
Some article has empty or null value. At this point every article shows up regardless if there are values in the inherited_roles field. Any suggestion is much appreciated.