当前位置:网站首页>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
边栏推荐
- 双指针进阶--leetcode题目--盛最多水的容器
- Future usage details
- Come out after a thousand calls
- Ouvrir des contrats à terme, ouvrir des comptes en nuage ou faire confiance aux logiciels des sociétés à terme?
- 394. String decoding - auxiliary stack
- 102. Sequence traversal of binary tree
- 剑指 Offer 03. 数组中重复的数字
- Tdan over half
- Webapi + form form upload file
- .Net Core3. 1 use razorengine NETCORE production entity generator (MVC web version)
猜你喜欢

470. 用 Rand7() 实现 Rand10()

EasymodbusTCP之clientexample解析

超分之TDAN

440. 字典序的第K小数字(困难)-字典树-数节点-字节跳动高频题
![Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger](/img/4e/2161fc448f4af71d9b73b7de64a17f.png)
Using quartz under. Net core -- operation transfer parameters of [3] operation and trigger

PC电脑使用无线网卡连接上手机热点,为什么不能上网

JVM class loading mechanism

Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)
![[ES6] promise related (event loop, macro / micro task, promise, await / await)](/img/69/ea3ef6063d373f116a44c53565daa3.png)
[ES6] promise related (event loop, macro / micro task, promise, await / await)

394. String decoding - auxiliary stack
随机推荐
Excel quickly and automatically fills the contents of a row on a blank cell
JS implementation private attribute
古代埃及希腊,数学用的什么进制
MySQL advanced index [classification, performance analysis, use, design principles]
XTask与Kotlin Coroutine的使用对比
[related to zhengheyuan cutting tools]
Open futures, open an account, cloud security or trust the software of futures companies?
vite配置proxy代理解决跨域
2022年流动式起重机司机国家题库模拟考试平台操作
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
394. 字符串解码-辅助栈
QT modification UI does not take effect
Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers
Add drag and drop function to El dialog
一些问题一些问题一些问题一些问题
209. Minimum length subarray - sliding window
stm32入门开发板选野火还是正点原子呢?
Element calculation distance and event object
flink 学习(十二)Allowed Lateness和 Side Output
[appium] write scripts by designing Keyword Driven files