JavaScript -- syntax 3 -- array, javascript -- 3 --

Source: Internet
Author: User

JavaScript -- syntax 3 -- array, javascript -- 3 --
JavaScript -- syntax 3 -- array I. Experiences

 

Ii. Code
1 <! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> 2 21 * Two Methods of array definition in js: 22*1, var arr = []; var arr = [3, 1, 5, 8];23*2, using javascriptArray objectTo complete the definition. 24 * var arr = new Array (); // var arr = []; 25 * var arr1 = new Array (5 ); // The Array is defined and the length is 5.26 * var arr2 = new Array (5, 6, 7); // defines an Array with elements 5, 6, and 7; 27*28*29 */30 31 var arr = [100,]; 32 33 // alert (typeof (arr )); // object type Object34 35 // alert ("len:" + arr. length); 36 37 arr [4] = 348; // The JavaScript Array length is variable 38 arr [1] = "abc"; 39 arr [2] = true; 40 // traverse the array. 41 for (var x = 0; x <arr. length; x ++) {42 document. write ("arr [" + x + "] =" + arr [x] + "<br/> "); 43} 44 </script> 45 </body> 46 

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.