The ten latest front-end interview questions in 2018
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 <script>, <script async> and <script defer></strong>. </p>
<p>The main way to insert <a href="http://www.php.cn/wiki/48.html" target="_blank">javascript</a> code into an html page is through the script tag. There are two forms, the first is to insert js code directly between script tags, and the second is to introduce external js files through the src attribute. Since the interpreter will block the rendering of the rest of the page during the parsing and execution of js code, pages with a large amount of js code will cause long periods of blank space and delays in the browser. In order to avoid this problem, it is recommended to put all js references in before the </body> tag. </p>
<p>The script tag has two attributes, defer and async, so the use of the script tag is divided into three situations: </p>
<p>1.<script src="example.js">< /script><br>Without defer or async attributes, the browser will immediately load and execute the corresponding script. That is to say, before rendering the document after the script tag, it does not wait for the subsequently loaded document elements, and starts loading and executing them as soon as it is read. This will block the loading of subsequent documents; </p>
<p>2.<script async src ="example.js"></script>
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 CSS between and JS
AI-powered app for creating realistic nude photos Online AI tool for removing clothes from photos. Undress images for free AI clothes remover Swap faces in any video effortlessly with our completely free AI face swap tool! Easy-to-use and free code editor Chinese version, very easy to use Powerful PHP integrated development environment Visual web development tools God-level code editing software (SublimeText3)
Hot AI Tools
Undresser.AI Undress
AI Clothes Remover
Undress AI Tool
Clothoff.io
Video Face Swap
Hot Article
Hot Tools
Notepad++7.3.1
SublimeText3 Chinese version
Zend Studio 13.0.1
Dreamweaver CS6
SublimeText3 Mac version
Hot Topics

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.
