数组去重.html

<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin-top: 10px;

box-sizing: border-box;
}
span{
display:inline;
width: 200px;
height: 50px;
border: dashed red 2px;
}
span:hover{
background-color: pink;
border: yellow outset 2px ;
border-radius: 20px;
color: red;
}
</style>
</head>
<body>
<div style="width: 500px;height: 100px;background-color: rgba(233,56,48,.2);padding: 20px 0 0 10px;">

<script type="text/javascript">
//数组去重

function newarr(arr)
{
return Array.from(new Set(arr))
}
var arr=[23,5,67,25,26,5,899,26,24,23,899,5,67,9,25];
document.writeln('<span>去重前的数组:'+arr+'</span></p>')
document.writeln('<span>去重后的数组:'+newarr(arr)+'</span>')
</script>
</div>
</body>

posted @ 2020-05-11 12:05  阿向向  阅读(233)  评论(0编辑  收藏  举报