当前位置:网站首页>JS forms the items with the same name in the array object into the same array according to the name
JS forms the items with the same name in the array object into the same array according to the name
2022-04-23 17:43:00 【Front Thoughts】
demand : Today, I met one who is currently located in Guangzhou , According to the store data of all districts in Guangzhou in the past ! Design draft requirements : Classify the stores in a certain area according to the area ! But the back-end returns an array with all stores !
Design draft :
let tempArr = [];
for (let i = 0; i < that.storeList.length; i++) {
if (tempArr.indexOf(that.storeList[i].area_name) === -1) {
that.afterData.push({
name: that.storeList[i].area_name,
origin: [that.storeList[i]]
});
tempArr.push(that.storeList[i].area_name);
} else {
for (let j = 0; j < that.afterData.length; j++) {
if (that.afterData[j].name == that.storeList[i].area_name) {
that.afterData[j].origin.push(that.storeList[i]);
break;
}
}
}
}
console.log("88888888888888", that.afterData);
Get it done ! Go home for dinner !!!
版权声明
本文为[Front Thoughts]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230551156848.html
边栏推荐
- Using quartz under. Net core -- preliminary understanding of [2] operations and triggers
- Metaprogramming, proxy and reflection
- 01 - get to know the advantages of sketch sketch
- SystemVerilog(六)-变量
- Summary of common SQL statements
- Using quartz under. Net core -- a simple trigger of [7] operation and trigger
- Leak detection and vacancy filling (VIII)
- [simple understanding of database]
- Qt 修改UI没有生效
- How to use the input table one-way service to send (occupy less) picture files (body transmission)? FileReader built-in object involved
猜你喜欢
关于gcc输出typeid完整名的方法
Element calculation distance and event object
958. Complete binary tree test
SystemVerilog(六)-变量
In embedded system, must the program code in flash be moved to ram to run?
超分之TDAN
958. 二叉树的完全性检验
2022年上海市安全员C证操作证考试题库及模拟考试
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
92. Reverse linked list II byte skipping high frequency question
随机推荐
122. 买卖股票的最佳时机 II-一次遍历
[ES6] promise related (event loop, macro / micro task, promise, await / await)
2022年流动式起重机司机国家题库模拟考试平台操作
古代埃及希腊,数学用的什么进制
2021 Great Wall Cup WP
470. Rand10() is implemented with rand7()
给 el-dialog 增加拖拽功能
386. 字典序排数(中等)-迭代-全排列
198. 打家劫舍-动态规划
2021长城杯WP
How to change input into text
Index: teach you index from zero basis to proficient use
Header built-in object
SystemVerilog (VI) - variable
01-初识sketch-sketch优势
剑指 Offer 03. 数组中重复的数字
How to sort the numbers with text in Excel from small to large instead of the first number
Model problems of stock in and stock out and inventory system
Where is the configuration file of tidb server?
Qt 修改UI没有生效