Just came back from work, and today I'll talk to you. Hash array

Source: Internet
Author: User
Tags array length

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.