当前位置:网站首页>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;
}, []);
边栏推荐
- Xiaobai can also understand how the basic network 03 | OSI model works (classic push)
- C语言学习-Day_04
- Test how students participate in codereview
- Technology is as important as business. It is wrong to favor either side
- Memory compression for win10
- R語言plotly可視化:可視化多個數據集歸一化直方圖(historgram)並在直方圖中添加密度曲線kde、設置不同的直方圖使用不同的分箱大小(bin size)、在直方圖的底部邊緣添加邊緣軸須圖
- 迪米特法则
- Use aspese Cells convert Excel to PDF
- 12 necessary tools for network engineers
- R语言使用caret包的preProcess函数进行数据预处理:对所有的数据列进行center中心化(每个数据列减去平均值)、设置method参数为center
猜你喜欢
通俗易懂理解樸素貝葉斯分類的拉普拉斯平滑
邮件系统(基于SMTP协议和POP3协议-C语言实现)
Test how students participate in codereview
Error im002 when Oracle connects to MySQL
User authentication technology
[200 opencv routines] 212 Draw a slanted rectangle
Comparison between new and old interfaces
audiotrack与audioflinger
leetcode:522. Longest special sequence II [greed + subsequence judgment]
细说物体检测中的Anchors
随机推荐
The R language uses the preprocess function of the caret package for data preprocessing: Center all data columns (subtract the average value from each data column), and set the method parameter to cen
torchvision.models._utils.IntermediateLayerGetter使用教程
BufferedWriter 和 BufferedReader 的使用
mysql数据库汉字模糊查询出现异常
TCP/IP 详解(第 2 版) 笔记 / 3 链路层 / 3.4 桥接器与交换机 / 3.4.1 生成树协议(Spanning Tree Protocol (STP))
C語言學習-Day_04
R language plot visualization: plot to visualize the two-dimensional histogram contour map, add numerical labels on the contour lines, customize the label font color, and set the mouse hover display e
Es update values based on Index Names and index fields
通俗易懂理解朴素贝叶斯分类的拉普拉斯平滑
Xiaobai can also understand how the basic network 03 | OSI model works (classic push)
Comparison between new and old interfaces
C语言学习-Day_05
R语言plotly可视化:可视化多个数据集归一化直方图(historgram)并在直方图中添加密度曲线kde、设置不同的直方图使用不同的分箱大小(bin size)、在直方图的底部边缘添加边缘轴须图
软交换呼叫中心系统的支撑系统
border影响父元素的高度-解决方案
Flutter wechat sharing
Dimitt's law
This application failed to start because it could not find or load the QT platform plugin
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
es 根据索引名称和索引字段更新值