node数组去重的三种方法

第一种 利用Map数据结构去重

function a(arr) {
                let map = new Map();
                let array = new Array();  // 数组用于返回结果
                for (let i = 0; i < arr.length; i++) {
                    if (map.has(arr[i])) {  // 如果有该key值
                        map.set(arr[i], true);
                    } else {
                        map.set(arr[i], false);   // 如果没有该key值
                        array.push(arr[i]);
                    }
                }
                return array;
            }
            var arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5];
            console.log(a(arr)) //[1,2,3,4,5]

  第二种 使用ES6中的set是最简单的去重方法

let arr2 = [1, 2, 3, 4, 5, 5, 4, 3];
let res = [...new Set(arr2)];
console.log(res);

第三种 forEach+indexOf实现去重

var arr3 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5];
            var b = distinct(arr3);
            function distinct(arr) {
                result = [],
                    len = arr3.length; //len=10;
                arr3.forEach(function (v, i, arr3) {
                    var bool = arr3.indexOf(v, i + 1);
                    //从传入参数的下一个索引值开始寻找是否存在重复
                    if (bool === -1) {
                        result.push(v);
                    }
                })
                return result;
            };
            console.log(b.toString()); //1,2,3,4,5

 

node.js 各个版本下载

https://nodejs.org/dist/

https://blog.csdn.net/u013891584/article/details/102563658
https://blog.csdn.net/weixin_42557786/article/details/113244433
https://www.cnblogs.com/qiuer/p/5488854.html
https://www.csdn.net/tags/OtDacgysNjU3MzEtYmxvZwO0O0OO0O0O.html

 

查看端口情况 https://www.stephenwxf.com/post/76.html


*** https://blog.csdn.net/qq_37860634/article/details/110148064

 

 


http://hunandangjian.com:3000/test


湖南党建生产环境ip: 210.77.176.169

 

后台验证码: https://www.w3cschool.cn/article/49651507.html

 

代码扫码:https://www.cnblogs.com/cjw996/articles/16088631.html


node.js 跨域:https://www.cnblogs.com/eliteboy/p/13265171.html

 

远程桌面连接修改端口: http://www.win7zhijia.cn/win10jc/win10_36850.html

 


robot


http://hunandangjian.com:3000/robot


台式电脑密码: Zzylxa#.

 

菲连招 技巧
1

1 2 1 1 a a a 3 3 3

2

2 2 2 1 1 3 a a 3

18627981586

 

 

 

 

-A INPUT -p tcp -m state --state NEW -m tcp --dport 111 -j DROP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9000 -j DROP
#-A INPUT -p tcp -m state --state NEW -m tcp --dport 10022 -j DROP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 19001 -j DROP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 36534 -j DROP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 41004 -j DROP

 

 


如何通过个人电脑访问服务器上的虚拟机 : https://www.likecs.com/show-204258351.html

 

如何安装Vmware ESXi 6.7

https://blog.csdn.net/MssGuo/article/details/120577107


ESXi 安装虚拟机 https://jingyan.baidu.com/article/7f766daffd8e354101e1d086.html

 

阿里云dataworks的使用: https://help.aliyun.com/document_detail/369639.htm?spm=a2c4g.11186623.0.0.599e71a2SiPbVS#task-2158017


Nginx 负载均衡配置: https://www.jb51.net/article/246881.htm

 

posted @ 2022-09-15 10:49  Samuel-Leung  阅读(899)  评论(0编辑  收藏  举报