In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the methods of deleting array elements in javascript". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the methods of deleting array elements in javascript".
1.delete method: delete arr [1]
In this way, the length of the array remains the same, and arr [1] becomes undefined, but it also has the advantage that the index of the original array remains the same, and you can only use it if you want to traverse the array elements.
For (index in arr)
[xss_clean] ('arr [' + index+'] ='+ arr [index])
This traversal skips the elements of undefined
* this method will be supported by IE4.o later.
two。 Splice method of array object: arr.splice (1 ~ 1)
In this way, the length of the array changes accordingly, but the original array index also changes accordingly.
The first 1 in the splice parameter, which is the starting index of the deletion (from 0), in this case the second element of the array
The second 1, which is the number of deleted elements, deletes only one element, that is,'b'.
At this point, traversing array elements can be done in a normal way, such as for, because the deleted element is in the
Is not reserved in the array
* this method will not be supported until later on IE5.5
It is worth mentioning that while deleting array elements, the splice method can also add array elements.
For example, arr.splice is added to the array arr, and the two elements of dline e are added to the array
The resulting array becomes arr:'a','d','e','c'
Thank you for your reading, the above is the content of "what are the methods of deleting array elements in javascript". After the study of this article, I believe you have a deeper understanding of what the method of deleting array elements in javascript has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.