ejs / javascript check if array/object exists and is not empty

JavaScript
<% if(typeof papers == 'object' && papers.length > 0){ %>
  // whatever you want to do with 'papers' array
  <% } %>
Source

Also in JavaScript: