Javascript Object each(f)

Description

Javascript Object each(f)


/*/* ww  w.j  a  va2  s  .  co  m*/
 * Useful methods added directly to core objects, because that's the EH spirit.
 */
Object.prototype.each = function(f) {
 for(var key in this) {
  if(this.hasOwnProperty(key)) {
   f(key, this[key]);
  }
 }
};



PreviousNext

Related