84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
Above picture: obj stores the address, pointing to the object in the heap
So how is obj.a represented by a stack? It would be better to have a picture, thank you!
In v8, using {a: 1}的时候, 会创建一个隐藏类, 有一个属性a, 类型为number, 偏移为0. 当通过obj.a获取这个类的实例的a属性时, 会通过obj查到堆中的起始地址, 加上偏移就可以获取到obj.a的地址了. 在古老的浏览器中, 一个object就是一个单纯的hash table, 和PHP is very similar.
{a: 1}
a
number
0
obj.a
obj
object
hash table
PHP
In v8, using
{a: 1}
的时候, 会创建一个隐藏类, 有一个属性a
, 类型为number
, 偏移为0
. 当通过obj.a
获取这个类的实例的a
属性时, 会通过obj
查到堆中的起始地址, 加上偏移就可以获取到obj.a
的地址了. 在古老的浏览器中, 一个object
就是一个单纯的hash table
, 和PHP
is very similar.