2 ms·
You can see the description of how hidden classes work on the v8 wiki [1]. The short explanation is that the way v8 finds a hidden class is by following a chain
by ridiculous_fish 9y ago
You can see the description of how hidden classes work on the v8 wiki [1]. The short explanation is that the way v8 finds a hidden class is by following a chain of transitions starting at the empty class. Intermediate classes have to be kept around to retain the transitions.
That is, in code like:
function Point(x, y) {
this.x = x;
this.y = y;
}
v8 retains the hidden class for {x}, so it can find the hidden class for {x, y}.
[1] https://github.com/v8/v8/wiki/Design%20Elements#fast-property-access https://github.com/v8/v8/wiki/Design%20Elements#fast-propert...