Take you to analyze 7 JavaScript interview questions to remove the fake and keep the real
You will be surprised that so many people come to interview for jobs, and their resumes all seem to be very awesome. look. But if you ask them about it, you'll find they know nothing about it. I don't know if these resumes are real or just a gimmick. So like other interviewers, I have my own way of first making sure the person I'm interviewing is worthy of interviewing me - I can do it over the phone in half an hour.
#So if there’s something you think should be asked that isn’t in my 7 questions, it’s probably because I left it for a later part of the interview inside.
Also, I would like to say to those who may think that technical interviews do not really indicate whether a programmer is really good...
You are right. When I was a young programmer, I felt the same way if I was being interviewed for technical questions. But now that I have become an interviewer, I think this method can at least prove that those who pass the technical interview are much more likely to be excellent programmers than those who fail.
Finally, what I want to say is that I will not pass candidates just because they answered three or two questions incorrectly or did not answer the way I expected. However, if the other person cannot answer most of the questions, then I will give him a red light in my heart!
The following 7 JavaScript interview questions you should ask before the interview. Otherwise, your time will most likely be wasted.
This is a very simple question if you have ever used JavaScript. You have to know at least one way. But, despite that, in my experience, there are also a lot of people who claim to be JavaScript programmers who say they don't know how to answer this question.
Use the "new" keyword to call the function.
open/close curly braces.
var o = {};
You can also continue to ask, "Use the new keyword, under what circumstances do you create an object?" However, since I just want to eliminate some people, I will wait until the actual interview to ask these questions Ask when the time comes.
This is the same level of question as "how to create an object". However, there are also some people who can answer the first question but cannot answer this question.
Use the following code to create an array simply:
var myArray = new Array();
Creating an array is a very complicated process. But I would like to hear answers from candidates using square brackets.
var myArray = [];
Of course, we can continue to ask other questions, such as how to efficiently remove duplicate elements in JavaScript arrays, etc., but since we only need to know whether the candidate is worthy of further observation, I will ask questions about arrays It ends here.
This question is a little more difficult, and I don’t require the other party to answer it. However, this question is a quick way to determine a candidate’s technical proficiency: Do they really understand the programming language as well as they say they do?
Variable promotion means that no matter where a variable is declared in a scope, the JavaScript engine will move this declaration to the top of the scope. If you declare a variable in the middle of a function, such as assigning a variable in a certain line:
function foo() { // 此处省略若干代码 var a = "abc"; }
will actually run the code like this:
function foo() { var a; // 此处省略若干代码 a = "abc"; }
The danger with global variables is that someone else can create a variable with the same name and then overwrite the variable you are using. This is a headache in any language.
There are many ways to prevent it. The most common method is to create a global variable that contains all other variables:
var applicationName = {};
Then, whenever you need to create a global variable, just attach it to the object.
applicationName.myVariable = "abc";
Another method is to encapsulate all the code into an automatically executed function, so that all declared variables are declared within the scope of the function.
(function(){ var a = "abc"; })();
In reality, you may use both methods.
for(var prop in obj){ // bonus points for hasOwnProperty if(obj.hasOwnProperty(prop)){ // do something here } }
A closure allows a function defined within the scope of another external function to still be able to access variables within the external function even if everything else in the scope disappears. Bonus points if the candidate can explain some of the risks of using a closure in a for/next loop without declaring a variable to hold the current value of the iteration variable.
Regarding this question, we actually just want to see if the candidates have actually done JavaScript unit testing. This is an open-ended question with no specific right answer, but the person must be able to tell at least something about the process.
Welcome everyone to add.
The above is the detailed content of Let you analyze 7 JavaScript interview questions to remove the fake and keep the real. For more information, please follow other related articles on the PHP Chinese website!