Skip to content

Instantly share code, notes, and snippets.

@nirname
Last active December 11, 2015 07:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nirname/4564190 to your computer and use it in GitHub Desktop.
Making a unique javascript array using JQuery
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