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
var privarr = [];
privarr[' staprojquerygrid '] = [{
btn_id: ' But_add ',
roles: [' 2001 ', ' the ' of the '] ']
console.log (Privarr, PRIVARR.STAPROJQUERYGRID[0].BTN_ID)
The first line is to define an array Priarr, and the
js-Associative array usage:var arr = [];arr[' key1 '] = value1;arr[' key2 '] = value2;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
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:
Array Categories:
1, from the array of subscript divided into index array, associative array
Copy Code code as follows:
/* Index array, that is, an array that is usually called/
var ary1 = [1,3,5,8];
Array elements by index,
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
1 JS indexed arrays, associative arrays and static arrays, dynamic arrays2 3 Array Classification:4 51, from the subscript of the array into an indexed array, an associative array6 7 varAry1 = [1,3,5,8];8 //to fetch array elements by index, starting
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.