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>
<script>
// set是一种新的数据结构 是一个类数组
let arr = [1, 2, 3, 4, 5, 5, 4, 3];
let res = [...new Set(arr)];
console.log(res);
//数组去重
// map也是一种新的数据结构 也是键值对的集合 键值可以是任何的数据类型 可以是数字字符串对象 symbol 等等 但是我们之前的对象的key值只能是字符串
</script>
</body>
</html>
f12打开控制台,看效果
去重过后一共有五个不重复的,length代表的是个数。