Created
July 30, 2013 06:19
-
-
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.
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
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