Associative arrays in JavaScript

Source: Internet
Author: User

The so-called associative array (associative array) refers to objects in JavaScript.

Because a property in JavaScript is a key-value pair that can be accessed through obj[attr], it is similar to an array.

There are many other types of data structures:

Hash (hash)

Hash table (Hashtable)

Dictionary (dictionary)

The most confusing thing is that arrays in JavaScript can also use non-numeric storage values, such as:

var arr = [];

arr[' uname '] = ' uname ';

But the value added in this way does not affect his array attributes. The length of this array is still 0.

In fact, this is because objects such as arrays inherit object, so they also have basic properties of the object, and can store key-value pairs.

Not only an array, but all the other objects are available.

Associative arrays in JavaScript

Related Article

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.