Hidden classes - jellyfish-tom/TIL GitHub Wiki

[SOURCES]

https://medium.com/swlh/writing-optimized-code-in-js-by-understanding-hidden-classes-3dd42862ad1d

JS objects are implemented as what is called a HASH TABLE in memory. Hash tables make it much slower to retrieve a property on an object as compared to the contiguous buffer method used in non-dynamic programming languages. SO WHAT DO WE DO!? Well, the V8 JavaScript engine has got you covered.

DISLIAMER

Hash Tables are a data structure that allow you to create a list of paired values. You can then retrieve a certain value by using the key for that value, which you put into the table beforehand.

END OF DISCLAIMER

All you need to do as a developer is to learn about the solution provided by the V8 engine and to adopt coding practices accordingly for writing better-optimized code. The V8 engine provides the solution by providing a method called Hidden classes.

The purpose of hidden classes is to optimize the access time when retrieving a property on an object. This is achieved by sharing hidden classes among objects created in a similar fashion.

For more detailed explanation go to link in [SOURCES] (at the top of the page)