Memory consumption of arrays and objects in JavaScript?

A array generated by the

for loop and object , why does the array take up more memory than the object? The code is shown below (running on the node command line, as well as in the browser):

:

Apr.19,2022
The

array maintains a length attribute


if you think of it this way.. An array is actually an object and is extended on the basis of the object. Then the array will have one more layer of data than the object, so is it surprising that it takes up a little more memory?

[].__proto__.__proto__ === {}.__proto__  // true
Menu