练习题3_数组去重.html 489 B

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