1234567891011121314151617181920 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- let arr = [1,2,3,4,5,6,7,2,3,4,5];
- // 方法一
- // let newArr = new Set(arr);
- // newArr = Array.from(newArr)
- // console.log(newArr);
- // 方法二
- let newArr = [...new Set(arr)];
- console.log(newArr)
- </script>
- </body>
- </html>
|