Skip to content

Instantly share code, notes, and snippets.

@Xophmeister
Created February 26, 2013 13:28
Show Gist options
  • Select an option

  • Save Xophmeister/5038394 to your computer and use it in GitHub Desktop.

Select an option

Save Xophmeister/5038394 to your computer and use it in GitHub Desktop.
Urg! IE8...
// The easy way to get unique items from an array
Array.prototype.unique = function() {
return this.filter(function(s, i, a){ return i == a.lastIndexOf(s); });
};
// Translated into jQuery, so it works in IE8 :P
Array.prototype.unique = function() {
var array = this;
return $.grep(array, function(v, i) { return $.inArray(v, array, i + 1) == -1; });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment