Created
June 4, 2014 01:29
-
-
Save MadeByMike/09ac4b81dc9b8e08db33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method is kind of cheeky in its implementation. | |
// It uses the JavaScript’s object to add every item in the array as key. | |
// As we all know, objects accepts only unique keys and sure we did capitalize on that. | |
Array.prototype.unique = function() { | |
var o = {}, i, l = this.length, r = []; | |
for(i=0; i<l;i+=1) o[this[i]] = this[i]; | |
for(i in o) r.push(o[i]); | |
return r; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment