Defines why objects can use arrays

var str = "asdfssaaasasasasaa";
var json = {};
for (var i = 0; I < str.length; iPP) {

if(!json[str.charAt(i)]){
   json****[str.charAt(i)] =1** ;**
}else{
   json[str.charAt(i)]PP;
}

};
var iMax = 0;
var iIndex ="";
for (var i in json) {

if(json[i]>iMax){
     iMax = json[i];
     iIndex = i;
}

}
console.log ("the most frequent occurrence is" + iIndex+""+ iMax+"");

as above, json = {} created the object as follows: why can it be written as an array of json [str.charat (i)]

Mar.09,2021

json [] is the form of Object attribute access, and the array is also Object .

let json = { 'a': 1 };
console.log(json['a']);
let array = [];
console.log(array['length'])

how about comparing this?

var obj = {
    a: 1,
    1: 'b'
}
obj.a
obj['a']
obj.1
obj[1]
Menu