1.Array.from(new Set(需要去重的数组))
2.[...new Set(需要去重的数组)] --->展开运算符
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- 去重:
1.对去重有什么方法可以实现
2.真伪数组如何转换 arguments,剩余参数
-->
<script>
var arr=[1,2,3,4,3,4,2]//需要去重转换===>[1,2,3,4]
console.log(Array.from(new Set(arr)));//[1,2,3,4]
console.log([...new Set(arr)]);//[1,2,3,4]
function fn(a,...args){
// arge剩余参数
// console.log([...arguments]);
console.log(args);
}
fn(1,2,3)//[2,3]
</script>
</body>
</html>