Example of using delete to delete an array element in JavaScript [array length unchanged]

Source: Internet
Author: User
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.