The ten latest front-end interview questions in 2018

php中世界最好的语言
Release: 2020-09-01 15:50:43
Original
2971 people have browsed it

This time we bring you the latest front-end interview questions in 2018. We know that interviews are an essential part of front-end work. This time, the common front-end interview questions are sorted and summarized to help you get through the front-end interview. Big trouble. Let’s take a look.

[Related recommendations:Front-end interview questions(2020)]

1. Please describe the difference between cookies,sessionStorage and localStorage .

Software programming hopes to store some useful data persistently through some means. For network programming, this task is generally handed over to the server-side database or browser-side cookies. With the emergence of HTML5, web development has two options: Web Storage and Web SQL Database.

WebStorage comes in two forms: LocalStorage (local storage) and sessionStorage (session storage). Both methods allow developers to operate with key-value pairs set by js and read them when reloading different pages. This is similar to cookies.

1: Cookie data is always carried in the http request from the same origin (even if it is not needed), that is, the cookie is passed back and forth between the browser and the server. SessionStorage and localStorage do not automatically send data to the server, but only save it locally. Cookie data also has the concept of path, which can restrict cookies to only belong to a certain path.

2: The storage size limit is also different. Cookie data cannot exceed 4k. At the same time, because each http request carries a cookie, cookies are only suitable for saving very small data, such as session identifiers. Although sessionStorage and localStorage also have storage size limits, they are much larger than cookies and can reach 5M or more.

3: The data validity period is different. sessionStorage: is only valid until the current browser window is closed, and naturally cannot be persisted; localStorage: is always valid, and is saved even when the window or browser is closed, so it is used as a persistent Data; cookies are only valid until the set cookie expiration time, even if the window or browser is closed.

4: Different scopes, sessionStorage is not shared in different browser windows, even on the same page; localStorage is shared in all homologous windows; cookies are also shared in all homologous windows. shared.

5: Web Storage supports event notification mechanism, which can send data update notifications to listeners.

6: Web Storage’s api interface is more convenient to use.

2. Please explain the difference between
With the async attribute, it means that the loading and rendering of subsequent documents and the loading and execution of js scripts are performed in parallel, that is, asynchronous execution;

3.
With the defer attribute, the process of loading subsequent documents and the loading of js scripts (only loading but not execution at this time) are carried out in parallel (Asynchronous), the execution of the js script needs to wait until all elements of the document are parsed and before the DOMContentLoaded event is triggered.

3. Why is it usually recommended to place CSSbetween

and JS
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!