I'm trying to understand how JS engines like V8 handle objects in arrays and specifically how is memory allocated and is it efficient.
I have an array that is with objects not sorted and I produce an array that has those same objects in a sorted array
let obj1 = {'test': 'test1'};
let obj2 = {'test': 'test2'};
let obj3 = {'test': 'test3'};
let arr1 = [obj1,obj3,obj2];
...Do sorting and create a new array (no I don't want to destroy the previous)
let arr2 = [obj1,obj2,obj3];
Is the memory overhead only in the references created between the indices and the objects or am I actually duplicating the objects in memory space?