Skip to content

Instantly share code, notes, and snippets.

@ibolmo
Created March 6, 2009 22:28
Show Gist options
  • Select an option

  • Save ibolmo/75102 to your computer and use it in GitHub Desktop.

Select an option

Save ibolmo/75102 to your computer and use it in GitHub Desktop.
Array.prototype.find = function(value){
var result = [], i = 0;
for (var i = 0, l = this.length; i < l; i++){
var item = this[i];
if (item == value) result.push(i);
}
return result;
};
Array.prototype.find = function(value){
var result = [], item = this[0], i = 1;
do {
if (item == value) result.push(i);
} while (item = this[i++]);
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment