Javascript Object remove(key)

Description

Javascript Object remove(key)




Object.prototype.remove = function (key) {
   if (!this.hasOwnProperty(key))
      return/*from  w w  w  . java 2s . c  o  m*/
   if (isNaN(parseInt(key)) || !(this instanceof Array))
      delete this[key]
   else
      this.splice(key, 1)

 return this;
};



PreviousNext

Related