Wednesday, September 7, 2011

Useful javascript function: getObjectLength

function getObjectLength (o) {
  var length = 0;

  for (var i in o) {
    if (Object.prototype.hasOwnProperty.call(o, i)){
      length++;
    }
  }
  return length;
}

No comments:

Post a Comment