javascript - js attribute stack diagram
滿天的星座
滿天的星座 2017-05-19 10:42:02
0
1
584

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!

滿天的星座
滿天的星座

reply all(1)
黄舟

In v8, using {a: 1}的时候, 会创建一个隐藏类, 有一个属性a, 类型为number, 偏移为0. 当通过obj.a获取这个类的实例的a属性时, 会通过obj查到堆中的起始地址, 加上偏移就可以获取到obj.a的地址了. 在古老的浏览器中, 一个object就是一个单纯的hash table, 和PHP is very similar.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template