Remember a giant interview

Wujiaochang interview location in the office, next to the metro station, which is quite uncomfortable ah.

After entering the office area Reception little sister immediately gave a set of pen questions (actually the color of manufacturers .. really rich).

Written part

Do question 45 minutes, the actual answer nearly an hour.

A question what will be the back-end to front-end problems with the transfer id INT64 type? How to solve?

Restore site: look ignorant force. . Then suddenly thought of written questions before an algorithm, we asked to write a function, multiply a string, for example '12' * '40' = '480', although the title did not write out the algorithm, but know that the Number type is js length limit. Ah, the standard answer this question must be converted into a string of id!

The correct answer: js Number Type up to 2 ^ 53 - 1, and after a long long integer int64 spread beyond the front part will be lost. The solution is put into a string and then to the distal id.


Question two briefly browser cache mechanism What? Talk about their strengths and weaknesses.

Restore site: belongs to the fundamentals of questions, from the strong buffer cache to storage and consultation cookie, just write.

The correct answer: a little. Now that I think should be added is not a serviceWorker?


Question three can not think, it could not.


Question four with css draw the following progress bar (Figure find online, ignore the middle number)

Restore site: This question is finally written, it was already out of time, and no one called me. . . . Finally, write a little hastily handed in, not actually thinking.

The correct answer: Clip ring to achieve a progress bar


Five questions designed to use a dispatcher js, up to two concurrent tasks.

// 以下是场景,凭记忆写的,不一定正确
let promiseCreator = (task) =>{
    // do something
}
let scheduler = new Scheduler()
let runTask = (task, price) => {
    scheduler.add(promiseCreator(task))
    .then(()=> console.log(price))
}
runTask(task, 10)
复制代码

Restore site: seemingly seen this problem before, the idea is still there, create a class constructor, to achieve internal task queue, and then there are new tasks come in are updated about every queue, the task execution after notification to the next task. It should be noted that scheduler.add()the method can be called then, indicating that promise to return the object.

The correct answer: write and so on.

Interview part

Pen questions later finished two technical interviewer, a simple self-introduction after the start, the questions will revolve around the pen before. Interview an hour, pick some of the more interesting to write about:

Q: What's wrong with the back-end pass int64? So if Chuan Chuan number 5 with int64 what will happen? 5 is behind all 0 or all five?

A: js Number type have length restrictions, will remain beyond the maximum, so the back-end pass a string ok. Behind the problem is not clear.

Q: So you do not really understand what int64 that? But I know this question must be wrong?

answer. (Due to fear of brush algorithm questions asked, brushing experience problems before dared to mention, think a little too sensitive, the interviewer may be more willing to listen to your problem-solving ideas )

Q: It does not matter, let's look at the last scheduler This question is, can you talk about your thoughts?

A: Create two task queue, a memory task, a task scheduling of deposit, set a pending variable for recording currently perform the next task.

Q: Can I use a queue to write it? You must be defined pending the state do?

A thought for a moment :() queue can be optimized, pending can not.

Q: In fact, is not pending state. Because executed directly after a task is completed the next task just fine.

A :( heart is very confused, feeling the interviewer that's not right, but not finishing a good idea to refute, after the end of the interview the interviewer think it might be a deliberately wrong ..)

Q: There is a nested array, which only numbers and Array of two, how to draw?

A: recursion. Judgment with typeof.

Q: If the data. . . . This time I answer with isArray. . Really retarded, I did not hear what the interviewer asked yes. Should never be answer

Q: How useState such stable hook (after the component update status will not change)?

This is an open question, the interviewer said he did not read the source code, to discuss with me, although I do not understand anything. . . Took advantage of the self-closure characteristics defined hooks it

in conclusion

Must maintain confidence, seriously consider the interviewer to give you tips and answers, then do not need to fast (not to answer), clarify ideas when the answer is most important, because the interviewer want to move is not only good technical people , but also can solve their problems with people.

Will not encounter the subject do not rush to give up, since the interviewer gives you time to think we should talk about their own ideas, even if it is wrong.

Reproduced in: https: //juejin.im/post/5d05d856e51d45773d468605

Guess you like

Origin blog.csdn.net/weixin_33874713/article/details/93173340