JS uses the array length property to empty and truncate an array of small examples

Source: Internet
Author: User
Tags array length truncated

This article mainly introduces JS using the array length property to empty and truncated arrays of small examples, the need for friends can refer to

1. Use length to empty the array: The code is as follows: <script> var arr1 = [' aaa ', ' bbbb ', ' http://www.jb51.net '];     alert (ARR1);     arr1.length = 0; alert (ARR1);     Array is null </script> 2. Use the length truncated array: The code is as follows: <script> var arr1 = [' aaa ', ' bbbb ', ' C ', ' d ', ' e '];     Arr1.length = 3; alert (ARR1); Truncated array aaa,bbbb,c </script>

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.