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
1667
14
1426
52
1328
25
1273
29
1255
24

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.
