/ Published in: JavaScript
object.forEach
void object.forEach(function callback(item, value)[, thisObject])
Expand |
Embed | Plain Text
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(); var thisp = arguments[1]; for ( i in this ) { if ( this.hasOwnProperty(i) ) fun.call(thisp, i, this[i]); } }
You need to login to post a comment.
