Javascript Array sparseLength()

Description

Javascript Array sparseLength()


////////////// Helper methods to handle histogram sparse arrays
Array.prototype.sparseLength = function() {
  var c = 0;//ww  w.j a  v  a2 s  .  co m
  for(a in this) {
    if(!isNaN(a)) {
      c++;
    }
  }
  return c;
}



PreviousNext

Related