Return to Snippet

Revision: 11897
at February 23, 2009 00:59 by Sephr


Initial Code
Object.prototype.forEach = function(fun /*, thisp*/) {
  // if this gets called on an array, use appropriate forEach
  if ( Object.prototype.toString.call(this) == "[object Array]" ) return Array.prototype.forEach.apply(this, Array.prototype.slice.call(arguments));
  if ( typeof fun != "function" ) throw new TypeError();
  let it = Iterator(this), thisp = arguments[1];
  try {
    while (true) {
      fun.apply(thisp, it.next());
    }
  } catch (err if err instanceof StopIteration) {}
}

Initial URL

                                

Initial Description
object.forEach
=========
*Requires JavaScript 1.8*

`void object.forEach(function callback(item, value)[, thisObject])`

Initial Title
object.forEach [JS 1.8]

Initial Tags
object

Initial Language
JavaScript