Javascript&jquery. Arrays

Source: Internet
Author: User

Array

An array is a special type of variable that can store a value or store multiple values.

Create an array

When creating an array, declare the array variable, use the keyword VAR, the value of the array is enclosed by a pair of brackets ([]), the values in the array are separated by commas (,), and the values in the array can be numbers, strings, and Boolean values.

Accessing and changing values in an array

The array uses the index to determine the value, and the index is used to get the values in the array when accessing the values in the array.

<! DOCTYPEHtml>
<Htmllang="EN" >
<Metacharset="UTF-8" >
<Title> Array </Title>
</Head>
<Body>
<Script>
var ShoppingCart = [ ' Apple ', "Litchi";
Shoppingcar[0]= document. write ( ":" + shoppingcart[0]);
</SCRIPT>
</BODY>
</HTML>
Test questions

1. How do I create an array?

A: When creating an array, declare the array variable, use the keyword VAR, the value of the array is enclosed by a pair of brackets ([]), the values in the array are separated by commas (,), and the values in the array can be numbers, strings, and Boolean values.

2, the array of subscript is from a few start?

Answer: 0

3, how to access the array?

A: Use the index to get the values in the array.

4, how to modify the value of the array?

For:shoppingCart[0]=‘‘;

5. What can the array store?

A: Number types, String types, and Boolean types

6. Can arrays be stored in an array?

Answer: You can

Javascript&jquery. 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.