Write a topic

Binding events?

General binding event + event proxy

Marches: Determine if a DOM element follows a CSS selector

Draw a triangle, right?

Simple Ajax implementation?

Implement the new operator?

Realize the promise. All ()?

Ideas:

1. Pass an iterable/array (can contain promise, normal data)

2. Promise parallel execution

3. If a promise is rejected, the promise fails

4. The output array is consistent with the input array

5. After all data is resolved, the result is returned

Testing:

Hand-written stabilization?

Hand throttling?

Handwritten deep copy?

Handwritten array deduplicate?

Handwritten clearfix?

Handwritten instanceof?

Instanceof: Determine if the left prototype exists on the right prototype chain

If the final prototype = NULL, it does not exist in the prototype chain, otherwise it exists

Handwritten typeof?

Implement promise to load an image?

Basic sorting algorithm

Insert sort?

Ideas:

1. Start with the second number

2. If you’re bigger than it, move to the back

3. And so on to the last number

The first comparison: 4 and 5 compare, 4<5, 4 inserted in front of 5, 5 back

3<4<5, insert 3 in front of 4, [4,5] in back

[3,4,5] [3,4,5] [3,4,5] [3,4,5] [3,4,5] [3,4,5] [3,4,5

Fourth: 1 compared with 5-tetrafluorobenzoic [2], 1 < < 3 < 2 and 4 < 5, inserted into the front of 2, 1, 5-tetrafluorobenzoic [2] to the rear

Quick sort?

Ideas:

1. Partition: Select an arbitrary “baseline” from the array. All elements smaller than the baseline are placed before the baseline and all elements larger than the baseline are placed after the baseline (if there is only one number).

2. Recursion: Recursively partition subarrays before and after the base

Bubble sort?

Array length: length

Number of sorts: n = 0, n++, number of sorts length-1

I = 0, I ++, length -n

Selection sort?

Ideas:

1. Find the smallest value in the array, select it and place it first

2. Then find the second smallest value, select it and place it in second place

3. In the same way, the n-1 round is executed

Merge sort?

Ideas:

1. Split: Split the array in half and recursively “split” the subarrays until they are separated into individual numbers

2. Merge: Merge two numbers into an ordered array, and then merge the ordered array until all the subarrays are merged into a complete array

Merge two ordered arrays:

1. Create an empty array res to store the sorted array

2. Compare the headers of two ordered arrays. The smaller one is removed from the queue and pushed into the RES

3. Repeat step 2 if both arrays still have values

Depth-first traversal – Tree?

Depth-first traversal: Search for branches of the tree as deep as possible

Skills:

1. Access the root node

2. Perform depth-first traversal for children of the root node one by one (recursion)

Execution order: according to the above tree structure a B D E C F G

Breadth-first traversal – Trees?

Breadth-first traversal: The node closest to the root is accessed first

Skills:

1. Create a queue and add the root node to the queue

2. Step out of line and interview the team leader

3. Join the children who lead the team one by one

4. Repeat steps 2 and 3 until the queue is empty

A B C D E F G

Scenario questions

Implement fuzzy query?

Under the big div, two small divs, mouse over one div, change the style of the other div?

How does Vue implement the login method?

1. Go to the login page, and enter the user name and password

2. Click the Login button to trigger the Login method of methods in the current component

3. In the login method, pass the account and password as parameters to the doLogin method in Vuex and call this.$store.dispatch(“doLogin”)

4. In the doLogin method, the login request Api is asynchronously invoked. When the server returns a token, the token is stored through the localStorage

5. After calling the doLogin method, return the Promise object, and then continue to call the Vuex getUserInfo method to get the user information

6. Go to the specified page

How do I maintain the login status of Vue? Refresh or current page?

1. The localStorage store token

2. Set the globalguard router.beforeEach(to,from,next) — verifies routes before entering

3. Obtain the token in localStorage using getItem

4. If the route to be entered requires the login permission of requiresAuth- to.meta. RequiresAuth – login permission is set in the meta field of the defined route, further determine whether token exists, if there is, directly enter the route next(), Otherwise, go to the login page and log in again

5. If the incoming route does not require the login permission of requiresAuth, the incoming route can be directly accessed