Skip to content

Instantly share code, notes, and snippets.

@nirname
Created January 18, 2013 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirname/4563116 to your computer and use it in GitHub Desktop.
Save nirname/4563116 to your computer and use it in GitHub Desktop.
Iterating over Arrays for IE using JQuery
if (typeof Array.prototype.indexOf == "undefined") {
Array.prototype.indexOf = function(value) {
for (var i = 0; i < this.length; i++) {
if (this[i] == value) {
return i;
}
}
return -1;
}
}
if (typeof Array.prototype.filter == "undefined") {
Array.prototype.filter = function(proc) {
var result = []
for (var i = 0; i < this.length; i++) {
if (proc(this[i])) {
result.push(this[i]);
}
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment