Posted By

inamorix on 10/23/07


Tagged

js


Versions (?)

Object.prototype.list (Firefox only)


 / Published in: JavaScript
 

  1. Object.prototype.__defineGetter__('list', function (dep) {
  2. var r = [];
  3. var ind = '';
  4. var dep = (typeof(dep) == 'number') ? ++dep : 0;
  5.  
  6. for (var i = 0; i < dep; i++) { ind += '\t'; }
  7. for (var i in this) {
  8. if (this.hasOwnProperty(i)) {
  9. var is_obj = (typeof(this[i]) == 'object');
  10.  
  11. r.push(ind + i + ': ');
  12. r.push(is_obj ? '' : this[i]);
  13. r.push('\n');
  14. r.push(is_obj ? arguments.callee.apply(this[i], [dep]) : '');
  15. }
  16. }
  17.  
  18. return r.join('');
  19. });

Report this snippet  

You need to login to post a comment.