Javascript Object toString()

Description

Javascript Object toString()

Object.prototype.toString = function() {
    try {/* ww w .j  a v a2  s  .c o  m*/
        return JSON.stringify(this);
    } catch(circular_structure) {
        return '[object Object]';
    }
};

Javascript Object toString()

Object.prototype.toString = function() {
  var keys = Object.keys(this);
  var values = [];
  keys.forEach(function(x) {
    values.push(this[x]);/*www .  j  a va 2  s.com*/
  },this);
  console.log(values);
  var cnt = 0;
  while (cnt < keys.length) {
    
  }
};



PreviousNext

Related