Discover javascript associative array, include the articles, news, trends, analysis and practical advice about javascript associative array on alibabacloud.com
type of PHP array-associative array
What is a php associative array?
In the previous article we introduced the "type of PHP array-numeric index array", today we specifically introduced the next associative array.
In addition to array index arrays,
This article summarizes the usage summary of JavaScript associative array, and the friend who has to understand the JS associative array can refer to this article.
Just learn JS when it seems to remember that there is no associative array js, write
Standard JavaScript is included in the support hash associative array, after finding data and testing, about standard JavaScript contains hash associative array operation memo as follows1. Hash associative array definitionDefine an empty array
TIP: The content is extracted from the JavaScript authoritative guide, and students who have read the book can ignore this article.How to access the properties of an object:obj.attr;obj["attr"];The most important difference between the two is that
Title, the original has been mistakenly thought JS inside can not be like PHP definition associative array, such as a["color"]=red;
But a few days ago, I found it possible.
Would you like to ask if this is a more efficient way of defining than
The usual array is populated with an implicit or display of the specified array subscript, but the array in JS can be assigned the element in the form of a name, which forms an associative array, such as:
Copy Code code as follows:
Copy Code code as follows:
var beatles = ["John", "Paul", "George", "Ringo"];
The Beatles array above is a typical example of a traditional array: the subscript for each element is a number, and the number increases by 1 for each
The usual array is implicitly or displays the specified array subscript when it fills, but the array in JS can be assigned a value in the form of a name, which forms an associative array, such as:var arr=New Array (); arr["China"]=
The principle of associative (hash) arrays:Hash algorithm: Receive a string to calculate a number that is not duplicated as much as possibleDifferent strings, calculate the number as different as possibleThe same string, the calculated ordinal must
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.