Traditional Culture Encyclopedia - Traditional culture - Summary of Web Front-end Interview Questions in 2020 (1)

Summary of Web Front-end Interview Questions in 2020 (1)

The article that Bian Xiao wants to share with you today is a summary of the topics of Web front-end interview in 2020. Because there are many small series to introduce to you separately, let's take a look at the first part with small series today. I hope these interview questions can be helpful to friends who are looking for Web front-end related jobs.

1. How many basic specifications are there for writing JavaScript?

1) Don't declare multiple variables on the same line;

2) Please use = = =/! = = Compare true/false or numerical values;

3) replace the form of newObject with the literal quantity of object;

4) Reduce the use of global functions and global variables;

5) 5) The switch statement must have a default branch;

6)if statement must use braces;

7) variables in the 7)for-in loop;

The scope should be clearly defined with the var keyword;

So as to avoid global pollution.

2. What about the balanced binary tree?

Self-balanced binary search tree

Also known as AVL tree.

Has the following properties:

1) It is an empty tree or its left and right subtrees.

The absolute value of the height difference does not exceed 1,

The left and right subtrees are balanced binary trees.

2) A balanced binary tree must be a binary lookup tree, and vice versa.

3) Common implementation methods of balanced binary tree include red-black tree, AVL,

A scapegoat tree, tree, stretch tree, etc.

The node formula of the least binary balanced tree is as follows:

F (n) = f (n-1)+f (n-2)+1Remarks:1is the root node.

F(n- 1) is the number of nodes in the left subtree,

F(n-2) is the number of nodes in the subtree on the right.

3. What is the solution to clear the floating and solve the vertical outer margin overlap?

Problem description:

1) does not set the width and height of the parent element, and the size is supported by the child element;

Once the child element floats, the height of the parent element collapses.

2) The child element sets the top of the margin that will be applied to the parent element;

This will cause vertical outer margins to overlap.

. Clearfix:: yes,. clearfix::before{

Content: "";

Display: table;

Clear: both;

}

4. Session storage, local storage and cookie?

Similarities:

Are all used for cached data stored at the browser end;

Difference:

1) whether the stored content is sent to the server.

After the Cookie is set, the data will be sent to the server.

Causing a certain waste of broadband; Xxxstorage will save data.

Going to the local area will not cause broadband waste;

2) Different data storage sizes

Cookie data cannot exceed 4K, which is suitable for session identification;

Xxxstorage data storage capacity can reach 5m;

3) The validity period of data storage is different

Cookies are only used when the cookied Expiration Time is set.

It has been valid until now, even if the window or browser is closed;

SessionStorage, which is valid only before closing the browser;

LocalStorage, data storage is permanent and effective;

4) Different ranges

Cookie and localStorage are located in the same source and window.

Are enjoyed by * * *;

SessionStorage is not in a different browser window.

Enjoy in * * *, even on the same page;

5. Judge whether a word is palindrome?

Palindrome refers to putting the same word or sentence,

Hereinafter, the position is reversed or reversed,

Create a scene with a head-to-tail loop,

This is called palindrome, also called palindrome.

Like Kaka Redivid.

letcheckPalindrom =(str)= & gt; {

returnstr===

str.split(“”)。 Reverse (). Join ("");

}

6. Exchange two integers without using temporary variables?

Enter a=3, b= 1,

Output a= 1, b=3.

letswap=(a,b)= & gt; {

b = b-a;

a = a+b;

b = a-b;

return[a,b];

}

7. Please write at least five new tags in html5, and explain their semantics and application scenarios?

Section: defines a chapter in the document;

Nav: define a chapter that only contains navigation links;

Header: defines the header of a page or chapter;

It usually contains a logo, a page title and a navigable table of contents.

Footer: defines the tail of a page or chapter;

It usually contains copyright information, legal information links and addresses for feedback suggestions.

Narrator: Define the content with low relevance to the page content,

If it is deleted, the rest is still reasonable.

8.8. What is the difference between GET and post requests in the cache?

A get request is similar to a lookup process, in which a user obtains data,

You don't have to connect to the database every time, so you can use the cache.

The post is different. Post generally does the work of modification and deletion.

So you have to interact with the database, so you can't use the cache.

So get requests are suitable for request caching.

9. How to solve the asynchronous callback hell?

Commitment, Generator, Asynchronous/Wait

10. lazy loading and preloading of pictures?

Pre-loading: pre-loading pictures,

When users need to view it, they can directly

Render from local cache.

Delayed loading: the main purpose of delayed loading

As an optimization of the server front end,

Reduce the number of requests or delay the number of requests.

The essence of two technologies:

Their behavior is the opposite,

One is to load in advance,

One is that it is slow and doesn't even load.

Lazy loading has a certain impact on the front end of the server.

Stress relief effect,

Preloading will increase the pressure on the front end of the server.

1 1.bind, apply and call. What's the difference?

By applying and calling to change this direction of the function,

The first parameter of these two functions is the same,

Indicates the object to which you want to change the pointing.

The second parameter apply is an array.

And the form of the call is arg 1, arg2. ...

Change the scope of this through bind.

A new function will be returned,

This function will not be executed immediately.

12.js How to control loading one picture at a time, and then loading the next one?

Method 1:

var obj = new image();

obj . src = " #/2 1 . jpg ";

obj.onload=function(){

document.getElementById("pic ")

. innnerHTML =

}

load cargo