title: jquery - how to select the id and last element of the longest out of four arrays?
body: <p>I have four DIV elements on my page. Each has it's own array which I attached using data().</p>
  
  <p>Depending on user interaction (on page navigation) jquery stores loaded element IDs in one of the arrays.</p>
  
  <p>The setup and pushing elements works and looks like this:</p>
  
  <pre><code>$('div:jqmData(role="panel")').each(function(index) {
      if ( $(this).jqmData('hash') == 'history' ) {
           var id = $(this).jqmData('id');
           $(this).data("stack", []);
           // inital entry = startpage
           $(this).data("stack").push('#'+$(this).find('.starter').attr('id')); 
           }
  }); 
  </code></pre>
  
  <p>Adding elements:</p>
  
  <pre><code>$('div:jqmData(role="page")').bind( "pagechange", function( event) {
        var $targetPanel = $( event.target ),                 
        $targetPage = '#'+ $.mobile.path.stripHash( hash );   
        $targetPanel.data("stack").push($targetPage);
        });
  </code></pre>
  
  <p>I now need to know which array is the longest and what the last entry was? </p>
  
  <p>No clue how to do that...</p>
  
  <p>Can't use maxValue or math, as I only have entries like #pageSome, #pageOther. There must be a better way than looping through all arrays, getting their length and trying to if-else highest value...</p>
  
  <p>Thanks for help!</p>