Created
July 30, 2013 05:13
-
-
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.
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 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