Skip to content

Instantly share code, notes, and snippets.

@saitamanodoruji
Created July 30, 2013 06:19
Show Gist options
  • Save saitamanodoruji/6110700 to your computer and use it in GitHub Desktop.
Save saitamanodoruji/6110700 to your computer and use it in GitHub Desktop.
This function removes duplicate from the array given as an argument and return an array which contains removed elements.
var removeDuplicate2 = function(a) {
var b = [], i = 1, j, k
while (i < a.length) {
k = a.length
for (j = 0; j < i; j++) {
if (a[i] === a[j]) {
b.push(a[j])
a.splice(i,1)
break
}
}
if (k == a.length) i++
}
return b
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment