当前位置:网站首页>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
边栏推荐
- MySQL advanced index [classification, performance analysis, use, design principles]
- Ouvrir des contrats à terme, ouvrir des comptes en nuage ou faire confiance aux logiciels des sociétés à terme?
- vite配置proxy代理解决跨域
- SiteServer CMS5. 0 Usage Summary
- Sword finger offer 22 The penultimate node in the linked list - speed pointer
- 关于gcc输出typeid完整名的方法
- Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger
- Node template engine (EJS, art template)
- Gets the time range of the current week
- 编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
猜你喜欢
Using quartz under. Net core - [1] quick start
Tdan over half
Matlab / Simulink simulation of double closed loop DC speed regulation system
Future 用法详解
If you start from zero according to the frame
Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger
470. Rand10() is implemented with rand7()
Leak detection and vacancy filling (6)
土地覆盖/利用数据产品下载
Advantages and disadvantages of several note taking software
随机推荐
MySQL installation
209. Minimum length subarray - sliding window
Qt 修改UI没有生效
ros常用的函数——ros::ok(),ros::Rate,ros::spin()和ros::spinOnce()
JVM class loading mechanism
JS implementation private attribute
Webapi + form form upload file
JVM类加载机制
Construction of functions in C language programming
MySQL进阶之索引【分类,性能分析,使用,设计原则】
386. Dictionary order (medium) - iteration - full arrangement
Use of todesk remote control software
Hcip fifth experiment
Index: teach you index from zero basis to proficient use
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
为什么有些人说单片机简单,我学起来这么吃力?
92. Reverse linked list II byte skipping high frequency question
Manually implement call, apply and bind functions
01-初识sketch-sketch优势
Client example analysis of easymodbustcp