Interview Summary 1. Interview Summary
Regular Expression
The regular expression used for email address verification. I first wrote the/^ (\ w) + (\. \ w) * @ (\ w) + (\. \ w) + $/. Later, the interviewer pointed out that \ w is a single character, so I quickly changed it to/^ (\ w +) + (\. \ w +) * @ (\ w +) + (\. \ w +) + $/, which is basically a pass. However, although in a regular expression, \ w is not equivalent to [A-Za-z0-9 _], \ w also contains Unicode characters, such as the Russian 'signature ':
1 var en = 'a'; // a2 var ru = 'hangzhou' in English; // Example 3 console in Russian. log (en. charCodeAt (0); // The 974 console. log (ru. charCodeAt (0); // 1072
But in JS, \ w is equivalent to [A-Za-z0-9 _], the following code prints false:
1 var str = 'hangzhou'; // specify 2 var pattern in Russian =/^ \ w + $/; 3 console. log (pattern. test (str); // false
Use MongoDB to implement an excuse for logon and Registration
Below is what I wrote
1 var mongoose = require ('mongoose'); 2 var db = mongoose. connection ('mongodb ://... ', 'username', 'Password'); 3 var UserSchema = mongoose. schema ({4 username: {type: String, required: true}, 5 password: {type: String, required: true} 6}); 7 var User = mongoose. model ('user', UserSchema); 8 db. on ('connect ', function (err, res) {9 if (err )//... 10}) 11 app. post ('login', function (req, res) {12 // perform data verification and encryption among 13 users. findOne ({username :..., password :...}, function (err, doc) {14 if (err )... 15 else if (doc) // login successful 16}) 17 })
That's right. I used ellipsis for a lot of uncertain points. For example, I forgot the specific syntax when I extracted the form information of post. Of course, the above Code is wrong in many places. For example, the connection of Line 1 should be:
1 mongoose.connect('', {user: 'user', pass: 'pass});2 var db = mongoose.connection();
For another example, the 8th rows should be:
1 db.once('open', function(){2 // ...3 })
Write a bubble sort
I didn't expect to ask such a simple sort, and I was quite flustered. I thought the interviewer might lose a question that won't embarrass me if I don't want it ......
Implement a focus chart rolling Module
I used jQuery to write a plug-in before, but I think it will be very troublesome to write it on paper. Recently, I was engaged in Vue. js, and it was very convenient to write such a thing with Vue. js.
1 <! DOCTYPE html> 2
Later, the interviewer thought that I did not ask me to write it, and the key was to get to dinner.
This is the first time I met such an interview. I used to give priority to verbal expressions, but I couldn't express myself clearly every time, because I did not do anything worth mentioning during my internship, writing code directly may be more suitable for me.
The interview questions are also quite basic, but I always feel that the interviewer doesn't seem to really want me to, so I just raised a few questions and went through the process ...... I wish I had thought too much.