Analysis on the usage of JavaScript-associated array

Source: Internet
Author: User
This article mainly introduces the use of JavaScript correlated arrays, and analyzes the concepts, definitions, and implementation skills of correlated arrays in the form of examples, if you need it, refer to the next article, which mainly introduces the usage of JavaScript associated array and analyzes the concepts, definitions, and traversal techniques of associated array in the form of examples. If you need it, refer

This example describes how to use Javascript to associate arrays. We will share this with you for your reference. The details are as follows:

Basic concepts:

"Join array" is an array with a special index method.It can be indexed not only by integers, but also by strings or other types of values (except NULL.The index value of the associated array is any scalar, which is called Keys and can be used later to retrieve the values in the array. The elements of the joined array have no specific order.

What does an associated array look like?

The Code is as follows:

Var defs = [W3C: "World Wide Web Consortium", DOM: "Document Object Model"];

How to define an associated array?

Var defs = []; defs [key] = value;

Note: key and value must be assigned different values.

How to traverse the associated array?

For (key in defs) {// variable key can be used directly. Var value = defs [key]; // The value of each key pair .}

The above is a detailed analysis of the usage of the JavaScript associated array. For more information, see other related articles in the first PHP community!

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.