Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete multiple elements of an array with splice in js

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail "how to delete multiple elements of the array with splice in js", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to delete multiple elements of the array with splice in js" can help you solve your doubts.

1. Splice method

Can be used to delete, add, replace and other operations on the array of js.

Delete function: used to delete elements

2. Grammar

Array.splice (index,num)

3. Parameters

First parameter: the location of the first item to be deleted

Second parameter: number of items to delete

4. Return value

Returns a new array containing deleted items.

5. Use examples

/ / Delete var arr = [1, 2, 3, 4] Var del = arr.splice (1mem2) / / delete two elements (including those with subscript 1) console.log (arr) / / 1Power4 here, the article "how to delete multiple elements of an array with splice in js" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it before you can understand it. If you want to know more about related articles, Welcome to 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report