ES 6 去重方法

一個卑微的小碼農發表於2020-11-17

<!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>

       function fn(ary){

           return Array.from(new Set(ary));

       }

       let arr=[1,2,3,4,5,6,1,2,3,4,5,6];

       let s=fn(arr);

       console.log(s);

    </script>

</body>

 

</html>

相關文章