Created
July 28, 2014 12:53
-
-
Save CooLNuanfeng/15d2925bd3b8b4f3600c to your computer and use it in GitHub Desktop.
一维数组去重
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 arr = [1,2,2,4,2]; | |
for(var i =0; i< arr.length; i++){ | |
for(var j=i+1; j<arr.length; j++){ | |
if( arr[i] == arr[j] ){ | |
arr.splice(j,1); | |
j--; | |
} | |
} | |
} | |
alert(arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment