Skip to content

Instantly share code, notes, and snippets.

@saitamanodoruji
Created July 30, 2013 05:13
Show Gist options
  • Save saitamanodoruji/6110403 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/6110403 to your computer and use it in GitHub Desktop.
This function removes duplicate from an array and returns the unduplicated array. It does not change the original array.
var removeDuplicate = function(a) {
var b = a, i = 1, j, k
while (i < b.length) {
k = b.length
for (j = 0; j < i; j++) {
if (b[i] === b[j]) {
b.splice(i,1)
break
}
}
if (k == b.length) i++
}
return b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment