March 2018 20 Arrays

Source: Internet
Author: User
Tags array length

While loop:

while (true) {}

Dead Loop:

while (true) {}

for (;;) {}

End Dead Loop:

while (true) {

if () {break; }

}

Examples of dead loops:

var aaa= ""  while (true) {       sea = prompt ("called Papa");       if (sea = = = "Papa") {break          ;   }}
View Code

Array:

Defining assignments using traversal

Array elements: Each item in an array

Array Length: The number of elements in the array (array name. length)

Array subscript (Index): The position of the array element in the array starts at 0

The array's subscript is the 0 element that is the first element of the array

Traversing for for

Common methods of arrays:

Push (); append one element at the end

Unshift (); Append an element in front of

Pop (); Delete last element

Shift (); Delete the first element

Iindexof (): Find the first occurrence of the position returned subscript not found return-1

LastindexOf (): Find the last occurrence of the position returned subscript not found return-1

Examples of arrays:

//Q: Admin Add user Information  Select how many each of the Var aa=[];//is  used to store user information Var  bb= prompt ("How many Users");//fill in the number of user information var  cc= "";// User information, for (var i=0; I<BB; i++) {     = prompt ("user" + (i+1) + "Information");     = cc ;  }alert (AA);
View Code

March 2018 20 Arrays

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.