es6 利用set实现数组去重
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>set实现数组去重</title> </head> <body> </body> <script type="text/javascript"> let set = new Set(["a",'b',"c",'c']) console.log(set.size) //3 let _arr = [...set]; console.log(_arr) </script> </html>
运行结果: