Skip to content

Instantly share code, notes, and snippets.

@CooLNuanfeng
Created July 28, 2014 12:53
Show Gist options
  • Save CooLNuanfeng/15d2925bd3b8b4f3600c to your computer and use it in GitHub Desktop.
Save CooLNuanfeng/15d2925bd3b8b4f3600c to your computer and use it in GitHub Desktop.
一维数组去重
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