JavaScript-Array Method application

Source: Internet
Author: User

Array Method Application
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" ><html><head><meta http-equiv="Content-type" Content="text/html; Charset=utf-8 "><title>Array Method Application</title>    <script type="Text/javascript">        varnums=New Array();varnames=New Array(3); names[0]="Tom"; names[1]="Jack"; names[2]="Mike."; names[3]="Alice"; names[4]="Alex";//Two ways to create an array        varstus1=New Array("Zhangsan","Lisi","Wangwu");varstus2=["hehe","Heihei","haha","HoHo"]; Names.sort ();//AscendingNames.reverse ();//Invert        //for iterating through an array         for(varI=0; i<names.length;i++) {Document.writeln (names[i]+"&nbsp;"); } Document.writeln ("<br/>");//foreach The index of the array is obtained.         for(varJinchSTUS2) {Document.writeln (j+":"+STUS2[J]); } Document.writeln ("<br/>");//stitch The elements in an array with the specified characters        varStr=names.join (",");        Document.writeln (str); Document.writeln ("<br/>");//In JavaScript, the index of an array can be a number, or it can be a string        varcitys=New Array(3); citys["Nanjing"]="Nanjing"; citys["Beijing"]="Beijing"; citys["Tianjing"]="Tianjin"; for(varCinchCitys) {Document.writeln (c+":"+citys[c]+"<br/>"); } Document.writeln ("<br/>");//Two sets of arrays        varGrade=New Array(3); grade["wbs14061"]=New Array("Little Tao","Super brother","Regulation regulation"); grade["wbs14081"]=New Array("Small Friends","Chinese Friends","db Friends"); grade["wbs14091"]=New Array("Little plum.","Puppy dog.","Little Donkey.");//Output All class student information         for(varGradenameinchGrade) {Document.writeln (gradename+":") for(varStuinchGrade[gradename]) {Document.writeln (grade[gradename][stu]+"&nbsp;&nbsp;")} Document.writeln ("<br/>"); } Document.writeln ("<br/>");</script></head><body></body></html>

JavaScript-Array Method application

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.