In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how es6 and js match two array objects". In daily operation, I believe many people have doubts about how es6 and js match two array objects. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how es6 and js match two array objects". Next, please follow the editor to study!
Determine whether the value used by two arrays is equal
This.list = [{user_type: 0, user_id: 1003, department_id: 1, department_name: "Company xx", mobile: "", realname: "Liao xx", com_name: "Ren Company", label: "Liao Jianping" Value: 1003}, {user_type: 0, user_id: 1004, department_id: 1, department_name: "Company leadership", mobile: "", realname: "he Jinsheng", com_name: "Ren Company" Label: "he xx", value: 1004}, {user_type: 0, user_id: 1005, department_id: 1, department_name: "Company leaders", mobile: "", realname: "Li Huan" Com_name: "Ren Company", label: "Li xx", value: 1005}] this.selectData = [{user_type: 0, user_id: 1003, department_id: 1, department_name: "Company xx" Mobile: ", realname:" Liao xx ", com_name:" Ren Company ", label:" Liao Jianping ", value: 1003}, {user_type: 0, user_id: 1004, department_id: 1 Department_name: "Company leaders", mobile: ", realname:" he Jinsheng ", com_name:" Ren Company ", label:" he xx ", value: 1004},]
Method one
Let result = [] for (let I = 0; I
< this.selectData.length; i++) { let obj = this.selectData[i] for (let j = 0; j < this.list.length; j++) { let aj = this.list[j] if (obj.value === aj.value) { result.push(aj) break } } } console.log("result", result) 方法二 let arr3 = this.selectData.filter(obj =>This.list.some (obj1 = > obj.value = = obj1.value) console.info ("arr3", arr3) this.result = arr3
Method three
Let arr4 = [] let arr5 this.list.filter (obj = > arr4.push (obj.value)) arr5 = this.selectData.filter (obj = > arr4.indexOf (obj.value)! =-1) this.result = arr5
At this point, the study on "how es6 and js match two array objects" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.