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 second line is to add a property staprojquerygird to the array, which is an array. Print result is But_add
var Unprivarr = [];//creates an empty array and assigns it to Unprivarr
unprivarr[' 1000 ']=[];//inserts an empty array into the empty array unprivarr, equivalent to unprivarr[1000]=[]
unprivarr[' 1000 ' [' AAA ']={' but_check1 ': 1, ' But_check2 ': 1};
Add a property named AAA to the empty array above (because JS is all objects, so the array is also an object, you can add properties and methods), the property value is a new object (that is, {' But_check1 ': 1, ' But_check2 ': 1}).
There is a big difference between this and the above. First the second line if [] inside is a number, then the array unpriarr the 1001th element is also an empty array (temporarily called X), the first 1000 elements are undifined,
If it's a variable, it's an array unpriarr element.
The third line is to add a property to x AAA, the attribute value is an associative array {' But_check1 ': 1, ' But_check2 ': 1}
You can use x[' but_check1 ' to get the corresponding value
And I want to do associative arrays add attributes to an object?
var Unprivarr = [];//creates an empty array and assigns it to Unprivarr
unprivarr[' 1000 ']=[];//inserts an empty array into the empty array unprivarr, equivalent to unprivarr[1000]=[]
unprivarr[' 1000 ' [' AAA ']={' but_check1 ': 1, ' But_check2 ': 1};
Console.log (unprivarr[1000].aaa[' But_check1 ')
This can output the result 1 correctly, or it can output the result with unprivarr[1000].aaa.but_check1, but if quoting is wrong
If the third line to {} inside the quotation mark removed, fourth will be an error, at this time can only use Unprivarr[1000].aaa.but_check1
Above this JS in the associative array and the general array of details is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.