Last active
December 11, 2015 07:08
-
-
Save nirname/4564190 to your computer and use it in GitHub Desktop.
Making a unique javascript array using JQuery
This file contains hidden or 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
if Array.prototype.unique == undefined | |
Array.prototype.unique = -> | |
filtered_array = [] | |
$.each this.sort(), (index, value)-> | |
filtered_array.push(value) if filtered_array.indexOf(value) == -1 | |
filtered_array | |
if Array.prototype.is_unique == undefined | |
Array.prototype.is_unique = -> | |
this.length == this.unique.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment