当前位置:网站首页>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;
}, []);
边栏推荐
猜你喜欢

C any() and aii() methods

Win10快捷键整理
![[200 opencv routines] 212 Draw a slanted rectangle](/img/cf/da8fff386d011c939946326c55671f.png)
[200 opencv routines] 212 Draw a slanted rectangle

mysql数据库汉字模糊查询出现异常
![[registration] infrastructure design: from architecture hot issues to industry changes | tf63](/img/75/b83aaf9610987f695eefe350f8170e.jpg)
[registration] infrastructure design: from architecture hot issues to industry changes | tf63

通俗易懂理解樸素貝葉斯分類的拉普拉斯平滑

【OpenCV 例程200篇】211. 绘制垂直矩形

手机影像内卷几时休?
![[hcie-rs review mind map] - STP](/img/b5/b89e59fe7f23bf23feeadb991acba7.png)
[hcie-rs review mind map] - STP

If you find any loopholes later, don't tell China!
随机推荐
oracle触发器 存储过程同时写入
我大抵是卷上瘾了,横竖睡不着!竟让一个Bug,搞我两次!
Ubuntu手動安裝MySQL
软交换呼叫中心系统的支撑系统
软件系统架构的演变
[so official interview] Why do developers using rust love it so much
多线程实现 重写run(),怎么注入使用mapper文件操作数据库
并发,并行,异步,同步,多线程,互斥的概念
es 根据索引名称和索引字段更新值
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.1 生成树协议(Spanning Tree Protocol (STP))
Arduino PROGMEM静态存储区的使用介绍
R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行center中心化(每个数据列减去平均值)、设置method参数为center
C语言学习-Day_04
Brother sucks 590000 fans with his unique "quantum speed reading" skill: look at the street view for 0.1 seconds, and "snap" can be accurately found on the world map
This application failed to start because it could not find or load the QT platform plugin
[STM32] Hal library stm32cubemx tutorial 12 - IIC (read AT24C02)
迪米特法则
2021 CSP J2入门组 CSP-S2提高组 第2轮 视频与题解
leetcode:968. 监控二叉树【树状dp,维护每个节点子树的三个状态,非常难想权当学习,类比打家劫舍3】
Quartz (timer)