当前位置:网站首页>Array object in JS
Array object in JS
2022-06-27 10:16:00 【Xiaaoke】
Array object de duplication
Determine the de duplication according to one word end of the array object
- Parameters
- arr: The array to be duplicated ( Array objects )
- id: According to the de duplication terminal name (string)
- Return value : Merged array objects ( Array objects )
function arrObjUniq(arr, id){
let obj = {
};
arr = arr.reduce((cur, next)=>{
obj[next[id]] ? '' : obj[next[id]] = true && cur.push(next);
return cur;
})
return arr;
}
Array objects are merged in the same way
Judge the merge according to one word end of the array object
- Parameters
- object: Target audience ( Array objects )
- sources: Source object ( Array objects )
- id: Merge word ends according to (string)
- Return value : Merged array objects ( Array objects )
function objMerge(object,sources,id){
const c = [];
object.forEach(item=>
sources(val => item[id] === val[id] && c.push({
...item, ...val}))
);
return c;
}
Array object grouping
const groups = dataObj.reduce((ini, product) => {
const [targetGroup] = ini.filter((grp) => {
const [first] = grp;
return first.grade === product.grade;
});
if (targetGroup) targetGroup.push(product)
else ini.push([product]);
return ini;
}, []);
边栏推荐
- I'm almost addicted to it. I can't sleep! Let a bug fuck me twice!
- [learn FPGA programming from scratch -47]: Vision - current situation and development trend of the third generation semiconductor technology
- Dimitt's law
- 小哥凭“量子速读”绝技吸粉59万:看街景图0.1秒,“啪的一下”在世界地图精准找到!...
- torch. utils. data. Randomsampler and torch utils. data. Differences between sequentialsampler
- [noodle classic] Yunze Technology
- 三层架构中,数据库的设计在哪一层实现,不是在数据存储层吗?
- Google browser chropath plug-in
- C any() and aii() methods
- C语言学习-Day_05
猜你喜欢
测试同学怎么参与codereview

别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!

This application failed to start because it could not find or load the QT platform plugin

leetcode:522. 最长特殊序列 II【贪心 + 子序列判断】

三层架构中,数据库的设计在哪一层实现,不是在数据存储层吗?

反编译jar包,修改后重新编译为jar包

Use aspese slides to convert PPT to PDF

. Net

Exception in Chinese character fuzzy query of MySQL database

leetcode:968. 监控二叉树【树状dp,维护每个节点子树的三个状态,非常难想权当学习,类比打家劫舍3】
随机推荐
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.1 生成树协议(Spanning Tree Protocol (STP))
Bluetooth health management device based on stm32
Reorganize common shell scripts for operation and maintenance frontline work
【STM32】HAL库 STM32CubeMX教程十二—IIC(读取AT24C02 )
.NET 中的引用程序集
C language learning day_ 05
Memory compression for win10
flutter 微信分享
并发,并行,异步,同步,多线程,互斥的概念
Ubuntu manually installing MySQL
2021 CSP J2 entry group csp-s2 improvement group round 2 video and question solution
Curiosity mechanism in reinforcement learning
dns备用服务器信息,dns服务器地址(dns首选和备用填多少)
[hcie-rs review mind map] - STP
mongodb跨主机数据库拷贝以及常用命令
Error im002 when Oracle connects to MySQL
Analysis of mobile ar implementation based on edge computing (Part 2)
Border affects the height of the parent element - solution
[从零开始学习FPGA编程-47]:视野篇 - 第三代半导体技术现状与发展趋势
Use aspese Cells convert Excel to PDF