I’ve read some articles about V8 .However, I still have Two questions in my head :
Q1– In V8 JavaScript engine : primitive values (like numbers and strings) and references to objects are always stored in the stack, while objects (including arrays and functions) are always stored in the heap but when (the references to objects or primitive values) is a property of another object it (the references to objects or primitive values) is stored in the heap to make the object properties together . is that 100% acurate ?
For example :
let name ="Tom"; // name is stored in the stack
let test ={name :"Tom", age:44}; // name and age are stored in the heap and test (the reference to the object) is stored in the stack
let temp ={t1:test}; // t1 is stored in the heap and temp (the reference to the object) is stored in the stack
Q2– this article is about Shapes ( a.k.a Hidden Classes ) and there is that code
const point = {};
point.x = 4;
point.y = 5;
point.z = 6;
and there is a photo in the article that represents how the object (point)
is look like in the memory :
I think this photo only represents ( contains ) the part that is on the heap ( in another words : this photo does not represent ( contain ) the reference to the object (point)
and that reference is stored in the stack ) so the photo must be like this :
So my second question is : is my thought right ( in another words : is my photo right ? ) ?