Js data structure

What is the data structure corresponding to Object in

js? What is its logical structure and physical structure?


first of all, Object is defined by ES, and ES does not specify what underlying data structure you need to use, so there is no solution to this problem.

I assume that what you want to ask is what V8 does for Object and what data structure it corresponds to. Let's move on.

Object is a castrated version of the hash table, which is explained below.

Let's first look at the definition of the hash table.

< H2 > hash table < / H2 >

hash table ( Hash table , also called hash table ) It is based on the key (Key) to directly access the data structure in the memory storage location . That is, it accesses the record by calculating a function about the key value and mapping the data of the desired query to a location in the table, which speeds up the search. This mapping function is called hash function , and the array in which records are stored is called hash table .

< H2 > my explanation < / H2 >

so Object corresponds to the castrated version of the hash table, which, better, should be Map, but Map is actually ordered, so update Java's SortedHashMap. The reason why Object is called castration means:

  • its key only supports strings, if not strings will be converted to strings.
  • it is not pure and is not a serious hash table.

so he may have some problems. For example:

  v8 src/base/hashmap.cc   					
Menu