preface
I have worked at Dafang for 6 years and been a front end interviewer for 3 years. I have compiled the interview questions and answers frequently asked by Dafang on my Github. I hope it helps.
The project address is: github.com/airuikun/We…
Selection of interview Questions
Big factory of one aspect of the test, everyone basically can brush on Google, see will, did not see to die. Through the brush problem, basically can make more than 85%.
However, in the second interview, you will find that the difficulty increases in vain. There are many technical points involved in one question, and it is rare to find the original question online, because most of the questions in the second interview are technical points extracted from the work, and candidates need to design solutions through their imagination and technical strength. Very test candidate front end ability.
Question 1: What platform compatibility issues for Windows and MAC were addressed during nodeJS development
Difficulty: Ali P5 ~ P6
Many candidates say that they are proficient in NodeJS development, but after the interview, they find that they are only at the demo level, they just download the example from the official website and run it casually, and think that nodeJS is really nothing more than that.
In fact, if you have really developed the large-scale engineering tool CLI with NodeJS, you will find that there are many compatibility problems with Windows and MAC systems, and even the API on the NodeJS official website is faulty and untrusted.
I’ll make a few random points, and you are welcome to add:
- Use cross-env for environment variable Settings, because export and set have system differences
- Windows does not support &, and concurrently performs Npm-Script with npm-run-all or CONCURRENTLY
- Async /await :util.promisify + async/await
- Don’t use fs.readFileSync on the official website. Use fs-extra instead
- Join (/ for Unix, \ for Windows)
There are so many more. I’m tired of writing
If you have a better answer or idea, please leave a comment on this topic on Github: github.com/airuikun/We…
Question 2: How to design a scenario where clicking a button in the browser can add an index.js file to your front-end project source file? Provide ideas
Difficulty: Ali P6 ~ P7
This question is a typical dafang two questions, the topic is simple to see understand, but really want to achieve can write a dragon out.
You can click on a button to generate a file in your front-end project code file.
In fact, if you look at the core core files of many cross-platform packages, you will find that they all implement the same principle. They all agree on a specification, and then implement a bridge to do permission penetration. That’s a lot to write down, so you can do your own research.
Another idea involves NPM + CLI + Node Server to implement. First implement an NPM plugin, register a command in bin, call this command when you run NPM start in your front-end project, and use this command to start a nod-dev-server. We then request the node-dev-server to create the index.js file via HTTP.
This question actually also has very simple method can achieve, have simple difficult, very flexible, of course your answer is more difficult and more in-depth, can reflect your creativity and strength.
What do you think? Any ideas? Feel free to leave a comment on my Github.
If you have any further thoughts or questions, please leave a comment on this topic on github: github.com/airuikun/We…
3. If an intern’s local git branch A is deleted by mistake and the code of branch A is not pushed to remote, how can he find the previous submission record and code of A
Difficulty: Ali P6 ~ P6 +
If you are a main coder or project leader of a front-end team, you must be very familiar with Git. Otherwise, code deletion and code loss will often occur. How do you solve this problem?
If you have a better answer or idea, please leave a comment on this topic on Github: github.com/airuikun/We…
If you use nodeJS crawler server IP is blocked by the specified site, how to unblock?
Difficulty: Ali P6 ~ P7
If you use NodeJS to implement a crawler to extract site content, you are likely to be blocked by someone’s anti-crawler mechanism. Solution is varied, of course, I didn’t do it perfect crawler service, but small, in this case I do several layers of IP pool implementation scheme is, when fetching failed, by automatically random switching IP agent pool to bypass the blocked, I simply write out the IP proxy pseudo code of the implementation of the principle, is actually a proxy to implement in nodejs, Very simple
http.createServer((req, res) = >{
request(
`http://xxx/${req.url}`,
{ proxy: "xxx.xxx.xxx:xxx" },
function(error, response, body) {
if(! error && response.statusCode ==200) {
res.end(body);
} else {
console.log(error); }}); }).listen(8888, () = > {console.log('run')});Copy the code
If you have a better answer or idea, please leave a comment on this topic on Github: github.com/airuikun/We…
Using Nodejs, convert base64 to a PNG file
Difficulty: Ali P5 ~ P6
const fs = require('fs');
const path = 'xxx/'+ Date.now() +'.png';
const base64 = data.replace(/^data:image\/\w+; base64,/."");// Data :image/ PNG; base64
const dataBuffer = new Buffer(base64, 'base64'); // Convert base64 code to buffer,
fs.writeFile(path, dataBuffer, function(err){// Write to the file with fs
if(err){
console.log(err);
}else{
console.log('Write successful! '); }})Copy the code
Usually, if you’ve done a base64 to PNG file, the interviewer will give you a bad example and ask you, “Do it. Do it. Do it
const fs = require("fs");
const util = require("util");
const imageData = await util.promisify(fs.readFileSync(fileUrl)); / / / example: XXX xx/xx. PNG
const imageBase64 = imageData.toString("base64");
const imagePrefix = "data:image/png; base64,";
console.log(imagePrefix + imageBase64);
Copy the code
If you have a better answer or idea, please leave a comment on this topic on Github: github.com/airuikun/We…
6. Please design a solution: there are three NPM plug-ins a, B and C, which will be updated frequently. After the front-end project NPM Run start is started, the three NPM plug-ins A, B and C are required to be updated to the latest version automatically
Difficulty: Ali p5+ ~ P6 +
There are many implementation schemes, so here is an idea:
When you register a global command called XXX, NPM run start, run the XXX command in parallel. The XXX command will fetch the latest information of a, B and C plug-ins through NPM info, intercept the version respectively, and then compare with the version of the three local plug-ins. If you find something different, update it.
If you have a better answer or idea, please leave a comment on this topic on Github: github.com/airuikun/We…
Question 7: Large file dump problem: Server A has A 1000G file, which needs to be forwarded to server C through server B, but server B has only 1 G memory. How to realize the large file dump
Difficulty: Ali P6 + ~ P7 +
This problem first implements the forwarding of the file stream in the case of insufficient memory,
After you’ve answered your question, the interviewer will surely ask you how to resume a post when you accidentally disconnect from the Internet.
What other problems can you think of with this whole process?
Death three ask, uncle ask you are afraid
MMP baby crying now, I have to go to the milk powder, the code is too long I will not stick, friends think about it, welcome to say your idea of implementation
If you have a good idea, please add to my Github: github.com/airuikun/We…
Question 8: How to realize Intranet penetration and port forwarding?
Difficulty: Ali p5+ ~ P6 +
In view of the classic port forwarding problems, I have written an article, easy to read, you can relax and relax “Biography of Tadpoles: Port Forwarding — A Legend of a Nightclub”.
conclusion
I also wrote some front-end advanced knowledge of the article, if you feel good can point to a star.
The blog project address is: github.com/airuikun/bl…
I am tadpole, senior front-end engineer, follow me to conquer the front-end technical difficulties. I hope to be helpful on the way to advance in front of friends and help everyone to enter their ideal enterprise.