There are many ways to process arrays, and JavaScript splice() is the most powerful. It can be used to insert, delete, or replace elements of an array. Let’s introduce them one by one!
1. Delete - used to delete elements, two parameters, the first parameter (the position of the first item to be deleted), the second parameter (the number of items to be deleted)
2. Insert -Insert an arbitrary element into the array at the specified position. Three parameters, the first parameter (actual position), the second parameter (0), the third parameter (the inserted item)
3. Replacement - insert any item element into the specified position of the array, and delete any number at the same time item, three parameters. The first parameter (starting position), the second parameter (the number of items to delete), the third parameter (to insert any number of items)
Look at the code below to understand