Considerations for array literal notation in JavaScript

Source: Internet
Author: User

JavaScript can initialize arrays by array literal notation, however, ie and other browsers differ in handling the empty values of the array literal notation, as shown in the following code.

<script type= "Text/javascript" >var testarray = [1,2,3,];alert (' Length of Testarray is: ' +testarray.length);//IE: Length of Testarray is:4; Chrome:length of Testarray is 3;var str = ' All-in-all, '; var testArray2 = Str.split (', '); alert (' Length of testArray2 is: ' +testar Ray2.length);//ie:length of TestArray2 is:4; Chrome:length of TestArray2 is 4;</script>


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Considerations for array literal notation in JavaScript

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.