Posted By

root_hacker on 04/13/11


Tagged

javascript


Versions (?)

javascript: get length of an object's children


 / Published in: JavaScript
 

if you need ecmascript 5 functions then use underscore.js

  1. Object.prototype.size = function() {
  2. var size = 0, key;
  3. for (key in this) {
  4. if (this.hasOwnProperty(key)) size++;
  5. }
  6. return size;
  7. };

Report this snippet  

You need to login to post a comment.