js 数组去重复

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	window.onload = function (){
		var arr = [11,13,22,11,5,13,7];

		function show(arr){
			var result = [ arr[0] ];
			for(var i = 0; i < arr.length; i++){
				if( toCon(arr[i]) ){
					result.push(arr[i]);
				}
			}

			function toCon(){
				for(var i = 0; i < result.length; i++){
					if( num == result [i]){
						result false;
					}
				}
				return true
			}
			return result;
		}

		console.log(show( arr ));
		
	}
	</script>>
</head>
<body>
	
</body>
</html>

  

posted @ 2015-04-26 22:07  mayufo  阅读(137)  评论(0编辑  收藏  举报