With regard to the relationship between arrays and objects in javascript, are arrays just another form of objects?

is an array just another form of object when it comes to the relationship between arrays and objects in javascript? Why do arrays have key?? Why is the final printed result the same? Ask the great god to answer this question about the array.

let arr=["a","b","c","d"]
let obj={
    "0":"a",
    "1":"b",
    "2":"c",
    "3":"d"
   }
for(let key in arr){
    console.log(arr[key])//a,b,c,d
}
 
for(let key in obj){
    console.log(obj[key])//a,b,c,d
}

Mar.06,2021
The

array is also an object. Try [] instanceof Object . for-in traverses keys, while for-of traverses the values of iterable objects. You can use for-in to traverse objects and arrays, but only for-of to traverse arrays.

  • How does javascript loop objects into arrays?

    the data provided by the backend is as follows [{avgInvestIndex:0,avgprice:3333},{avgInvestIndex:0,avgprice:3333},{avgInvestIndex:0,avgprice:3333},{avgInvestIndex:0,avgprice:3333},.......{avgInvestIndex:0,avgprice:3333}] the effect I want [0,3333],[0...

    Dec.08,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bcda74-303ec.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bcda74-303ec.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?