Preface (life first time to write nuggets article, hope light spray!
Although he is science college students, although contact front has one and a half years +, although review theory knowledge system has been a month +, although spent two weeks time specifically for various surface by it is easy to comb the bother of online, although have followed the bosses secretly steal headlines interview first hand information, but you really is too dish was hanging up! Secretly record a small notebook, review the interview when he is how stupid, mainly in order to record his interview heart road course, as well as to the knowledge point unrestrained (negative)(┬ _ ┬) also hope to have the interview headlines comrade can harvest some information
The text of the interview is attached (the answers are only my humble opinion, welcome correction).
- The headline interviewer is so friendly. He starts by asking questions about you, which is a huge relief. When did you get to the front end? What courses did you take in college? The most surprising thing is that the interviewer doesn’t even want to ask about his or her project experience.
- Talk about classes in JS. In traditional language, class inherits by copy, while JS inherits by prototype chain. Talk about prototypes. When the constructor is created, it generates a prototype object, essentially an object, that looks up the property on the prototype object through the prototype chain if it can’t find the property on the instance. Then talk about who you’re dating. Suddenly confused, as if you have never thought about this question, the brain suddenly filter, roughly said that the object is a reference data type in JS, etc. (ps: Lie on the bed surface after the mind, has been watching the prototype, the prototype chain of profound content thought grow slightly was smug, never want to interview for some of the most basic concepts I didn’t know how to answer, can’t also didn’t want to answer content guide to the familiar knowledge category, are too addicted to the knowledge itself, Not paying attention to the basic concepts of knowledge points and the staggered relationship between knowledge points)
- You know something about inheritance. In this article, I will discuss the advantages and disadvantages of Class inheritance and how parasitic Class inheritance solves the disadvantages of Class inheritance. I also want to talk about Class inheritance. Then write a handwritten inheritance. Basically a parasitic combinatorial inheritance is implemented.
- Let’s talk about some of the new es6 features: this in arrow functions, let,const block scoping, structure assignment, template strings, function defaults, and so on. The arrow function does not have this in it, so its “this” is searched by scope. I accidentally said “search by closure”. The arrow function in setTimeout is called through a closure. The arrow function in setTimeout is called through a closure.
- Flex layout: absolute+margin /BFC layout: absolute+margin /BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC layout: Absolute +margin/BFC
- Let’s talk about arrays. Map, filter, forEach, every, some, reduce, pop, push, shift, and so on. Implement a map function using reduce. Dish is original sin (┬ _ ┬), although the interviewer reminded or did not come true, after the face, the net searched once, very remorse is very self-reproach, feeling should be able to make! If at first you think too much and you can’t write anything, you can think of implementing a map without Reduce and then changing it to reduce form. I used to write a lot of call, apply, bind, debounce code on the Internet, but now I’m not able to write it because I don’t have a thorough understanding of the JS language and I’m still trying to figure out how to implement this, how to implement that, oh, I can write it myself after reading other people’s code. I will! I really great! A new problem on the meng force to find the answer, did not think of their own implementation can do, after the implementation of the implementation and other people’s poor in where. In the final analysis, the development should write more code, think more, pay attention to the combination of theory and practice!!
- Have an understanding of the JS event loop. JS is single-threaded, asynchronous to achieve non-blocking, and the event loop mechanism is a mechanism to coordinate the execution stack order of message queues. Added the script to start running the code from the top down, with asynchronous events would hang to the corresponding working thread execution, the main thread to continue execution at the back of the task, will stay after the completion of the asynchronous callback on the corresponding to the message queue, JS synchronization code execution after clears the task queue, and then take a macro task execution, empty micro task queue again, and said the macro, What are microtasks? You just said worker thread, but you said JS is a single thread execution? Browsers have multiple threads, such as rendering, timers, and network request threads, but that doesn’t prevent JS from being executed on a single thread. I asked the interviewer, that JS event cycle is what kind of ah? JS execution environments are browser and Node. The event loop of the browser V8 engine is basically what you said, but Node relies on the Libuv thread pool. (Originally have a deep understanding of browser and Node event loop, but did not expect to ask about JS event loop instinctively thought of the browser event loop, and ignored the Node event loop. It seems that I only know that the two event loops are different, and I have learned the relevant mechanisms in order to write out the execution order, but I have not thought about the relationship between JS and its host environment and the event loop, so I have become complacent.
- You’ve learned about data structures, so let’s find a path between any two nodes in a binary tree. (PS: Sorry I’m so lame!!)
Surface after summarizing
Although write code very dish, but always feel oneself answer of time do very good, but when lie in bed only then discover oneself answer of also very shit, experience is as follows:
- Toutiao is looking for people who are good at writing simple business logic and have a certain understanding of the theoretical basis. It’s about 6:4 open. And MY own code to write less, prepare are also all kinds of theoretical false, the result of a start on the sudden death!
- I still calculate to basic knowledge quite take seriously, often can see all sorts of article to a knowledge point, see window and the knowledge point that has harvest to oneself next steal away, record in small book on this. I thought it was a very excellent learning method, but I never thought that these “truths” which I think are normal often cannot withstand the test of facts, probably because they are too addicted to the “truth” of their own satisfaction, but they have not carried out further verification.
- On the handwritten code this piece, feel or usually to write more, more deeply dig the association of various implementations, so that the JS language will have a better understanding. Not I will do this, I will do that, hey new guy? I won’t!
- Guide the interviewer and direct questions to what you know and know, not what you assume. Big taboo ah, or because of the knowledge is not familiar with the reason!
A list of things that I think are really cool
- After looking at the front-end cache, we learned a lot and solved the long-standing confusion of the cache location
- Finally, we know how Jsonp really works
- Various cross-domain details, using promise to encapsulate the Jsonp implementation, blew my mind
- Js common memory leak and solution summary good summary
- JS handwritten code other good, feel anti – shake throttling also seen a better version
- Front-end security knowledge finally has a clear understanding of XSS and CSRF
Finally finished, for the first time in my life, good!