One of the front-end questions JavaScript (theoretical class)

Source: Internet
Author: User
Tags sessionstorage

one, please describe the cookies, sessionstorage, What is the difference between localstorage and session?
(1) A cookie is a site stored in the user's local terminal (client side) data (usually encrypted), the data size cannot exceed the cookie expiration time set by 4k,cookie , even if the window or browser is closed. Cookie data is always carried in the same-Origin HTTP request (even if not required) and is passed back and forth between the browser and the server.
(2) Sessionstorage and localstorage do not automatically send data to the server and are saved locally only. Sessionstorage and Localstorage have a storage size limit, but are much larger than cookies and can reach 5m or larger. localstorage  stores persistent data, the data is not lost after the browser is closed unless the data is actively deleted;sessionstorage   data is automatically deleted after the current browser window is closed.
(3) session: In a computer, especially in a network application, it is called "Session control". The Session object stores the properties and configuration information required for a specific user session. This way, when a user jumps between the application's Web pages, the variables stored in the session object are not lost, but persist throughout the user's session. When a user requests a Web page from an application, if the user does not yet have a session, the Web server automatically creates a Session object. When the session expires or is discarded, the server terminates the session. One of the most common uses of Session objects is to store the user's preferences. For example, if a user indicates that they do not like to view a graphic, they can store the information in the Session object. Note: Session state is reserved only in browsers that support cookies.

Second, how to realize the communication between multiple tabs in the browser?
WebSocket, Sharedworker, can also call Localstorge, cookies and other local storage methods. Localstorge when added, modified, or deleted in another browsing context, it triggers an event, and we communicate the page information by listening to the event and controlling its value. Note Quirks:safari throws an Quotaexceedederror exception when setting the Localstorge value in the non-trace mode.

Third, hash table

A hash table, also known as a hash table, is a data structure that is accessed directly from a key value. That is, it accesses records by mapping key code values to a location in the table to speed up lookups. This mapping function is called a hash function, and the array that holds the record is called the hash table.

Given table M, there is a function f (key), for any given keyword value key, after substituting the function if you can get the address of the record containing the keyword in the table, the table m is a hash (hash) table, function f (key) is a hash (hash) function.

One of the front-end questions JavaScript (theoretical class)

Related Article

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.