惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - rainbow727

ps-图层调整大小 js 根据关键字,进行mark背景色标记 时间戳转换为时间格式 ps-图层尺寸缩放 ps-窗口缩放比例调整 bug Extjs小例子 ps-填充色 ipv4,ipv6起止地址判断,网段判断 HTML li标签排列有空白间隙 Ext.js知识点纪要 PHP 文件内容处理 知识点小纪要 function函数 常用正则表达式 正则表达式的字符含义 邮箱正则表达式 jQuery相关面试题 js继承
jq 数组对象,重复数据进行合并
rainbow727 · 2023-11-17 · via 博客园 - rainbow727

  var bindif = [{

        "ifname": "Ge0/2/1",

        "ip": "20.1.1.1",

        "mask": "255.255.255.0"

    }, {

        "ifname": "Ge0/2/5",

        "ip6addr": "2000::254"

    }, {

        "ifname": "Ge0/2/5",

        "ip": "40.1.1.1",

        "mask": "255.255.255.0"

    }];

    var result = bindif.reduce(function (precurr) {

        var exist = pre.find(function (dt) {

            return dt.ifname === curr.ifname;

        });

        if(exist) {

            if(curr.ip && exist.ip6addr){

                    exist.ip = curr.ip;

                    exist.mask = curr.mask;

            }

            if(curr.ip6addr && exist.ip){

                exist.ip6addr = curr.ip6addr;

            }

        } else {

            pre.push(curr);

        }

        return pre;

    }, []);

    console.log(result);