In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the filter method in JavaScript to filter the original array to form a new array, which is very detailed and has a certain reference value. Interested friends must read it!
Use the filter method to filter the original array to form a new array
Scenario: remove some unwanted elements, for example, the id of each piece of data is the necessary data for later operation. In order to eliminate the defective data, we will do this:
Const data = [{name: 'mobile phone', price: 1000, id: 1}, {name: 'mobile phone case', price: 10, id: 2}, {name: 'hat', price: 50, id:''},] / / badlet newArr = [] for (let I = 0; I
< data.length; i ++) { if (data.id) { newArr.push(arr[i]) }} 掌握"过滤"思想,我们这样处理: const afterData = data.filter(item =>Item.id); these are all the contents of the article "how to filter the original array to form a new array in JavaScript using the filter method". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.