Skip to content

Instantly share code, notes, and snippets.

@very
Created October 17, 2012 04:15
Show Gist options
  • Save very/3903673 to your computer and use it in GitHub Desktop.
Save very/3903673 to your computer and use it in GitHub Desktop.
Array.prototype.forSome = function(callback, thisValue) {
if (typeof thisValue !== 'object') {
thisValue = null;
}
try {
for (var i = 0; i < this.length; i++) {
if (this.hasOwnProperty(i)) {
var returnValue = callback.call(thisValue, this[i], i, this);
if (typeof returnValue !== 'undefined') {
return returnValue;
}
}
}
} catch (error if error === StopIteration) {
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment