title: Compare array variables
body: <p>when trying to run the following code:</p>
  
  <pre><code>var pvals = new Array();
  pvals = "[" + $("#upcheck").val() + "]";
  pvals = $.parseJSON(pvals);
  pvals = pvals.sort(function(a,b) { return parseFloat(a.id) - parseFloat(b.id) } );
  
  for (var i = 0; pvals.length; i++) {
      if (i == 0) {
         //do something
      } else {
          if (pvals[i].id == pvals[i - 1].id) {
              //do something
          } else {
              //do something else
          }
      }
  }
  </code></pre>
  
  <p>Firebug within Firefox shows the following message "TypeError: pvals[(i - 1)] is undefined"
  Can anyone please help? I have defined pvals as an array.</p>
  
  <p>Thanks</p>
  
  <p>Ryan</p>