This article mainly introduces the use of JavaScript to delete array elements using delete, and analyzes the usage and precautions of delete to delete array elements using examples, for more information about how to delete Arrays Using delete in JavaScript, see the following example. We will share this with you for your reference. The details are as follows:
After javascript uses delete to delete some numeric values in the array, the length of the array remains unchanged.
The Code is as follows:
JavaScript deleteScript var a = [1, 2, 3, 4, 5, 6]; for (var I in a) {if (a [I] % 2 = 0) {delete a [I] ;}} console. log (a); console. log (. length); script
Run the following command:
I hope this article will help you design JavaScript programs.
For more JavaScript examples of using delete to delete array elements, see [Unchanged array length!