You can try it, create a new array, and then loop through the array you want to modify. If the subscript is not the number you want to delete, then push the element at this position into your new array. If The subscript is the number you want to delete, just continue to jump out of the loop In this way, after the loop ends, the new array is the array you need, and then assign it to the old array
Delete the ones with big subscripts first and then delete the ones with small subscripts
Replace the array with an object, use the delete method to delete, and the subscript will not change
The map method of the array removes the elements at the specified index position and generates a new array
Or direct filter method
You can try it, create a new array, and then loop through the array you want to modify. If the subscript is not the number you want to delete, then push the element at this position into your new array. If The subscript is the number you want to delete, just continue to jump out of the loop
In this way, after the loop ends, the new array is the array you need, and then assign it to the old array
To generate a new array:
Do not generate new array: