Hash algorithm: specifically accepts a string and calculates a number that is not duplicated as much as possible. The same string, the calculated number must be the same! Different strings, the calculated numbers are almost the same.
When adding elements: the subscript name is given to the hash algorithm, a unique ordinal number is computed, and the value is saved to the element of the array corresponding to the ordinal.
When reading an element: The subscript name is given to the hash algorithm, the exact same sequence number is computed, and the element value of the ordinal position is directly found. No need to traverse!
Special: Invalid associative array length property (always 0)
Traversal: Gets the name of each subscript in arr, saved in the variable key
for (var key in arr) {
arr[key]//Current Element
}
In general, when we open the news how do you know how you are in that place in the refresh, this time will use a hash array
Just came back from work, and today I'll talk to you. Hash array