What is asked of a novice JavaScript developer in interviews and in test tasks

Maria Kozhanova

Programmer and teacher

How are the interviews

Job interviews js programmerusually includes several steps. Usually, the first interview is with HR, who reads the questions written by the technician. In no way do I want to offend recruiters, they are the primary filter here. Such a conversation can also take place by phone or messenger without video. Usually they warn that the conversation is being recorded.

The second interview, if there is one, is already being conducted with the participation of techies. If there was work experience, they ask to describe the project. Without specifics, of course, everyone knows about the NDA.

It is possible that the next stage is a conversation with the people who make the decision whether to hire a specialist or not. But sometimes this is not required, you will learn about the results of the interview after the fact. I do not really like these conversations about life, but I understand why they are needed. Once in a large company there were just three stages, but the head of the department met with me for the second interview. According to the results of the interview, I did not want to work there for many reasons. But it was interesting what would happen at the technical stage. It was hot there, for an hour they asked questions from different areas, I didn’t always have an answer ready.

But often small companies do not want to waste time. Then, at the first interview, the candidate is already met by technical people, potentially future colleagues and bosses.

Technical stage: what questions are asked most often

At the interview, be sure to ask for an example of what you did. Once asked about the most difficult task that had to be solved. For some reason this has become the most difficult question.

They also ask about knowledge of frameworks. If you answer about JQUERY, then the next question is which of the “adults” did you deal with? Under “adults” they want to hear: Angular, React, Vue. Moreover, “had a deal” often for beginners means that you watched a video course or just started studying. This is fine. Because it is strange to demand thorough knowledge and experience from a junior – what kind of junior is he then? Experience comes with tinkering in a real project in parallel with persistent googling, preferably not only in Russian. It can be emphasized that the video course or resource for learning is not in Russian, you know English at least at a level suitable for reading documentation or understanding technical words.

Sometimes there are questions about arrow functions. This, I think, everyone who began to systematize their knowledge of JS already knows, learned by heart. They also like to talk about native Javascript: how to use native Javascript access elements of the DOM page? How about a specific one? What about tags?

If you are asked a question to which you do not know the answer, describe how you will look for a solution: “The answer to this question can be found in the search for such and such words.” Nowadays, there is no need to keep everything in mind. You need to know how to find information, how to form a request, how to separate the knowledge you are looking for from garbage and advertising. The main thing is to show that such situations do not scare you. Learning new things is the norm. Therefore, the usual practice is to assign an experienced mentor to the employee from the first day of work in the company, to whom the newcomer addresses incomprehensible questions that Google did not answer.

Weird questions also come up. Once they asked why I was learning Python (really, why). The interview was for a job that was not related to this language, but in the resume in the hobby section it was indicated about Python. But the company needed a workhorse to follow the rut of the job. So that side of the hobby seemed unusual. In general, strange questions are the main interview questions. They say a lot about the askers.

There are some patterns between what was said in the vacancy and what will be at the interview. Addressing you is definitely a marker. If you are yesterday’s student, perhaps such familiarity in the text of the vacancy does not hurt your eyes. People who have exchanged their fourth or fifth decade, most likely, should be wary. Although they will do it without my prompting. Also, the advantages of the “corporate events” type should not pass by people who are introverts. Bonuses in the form of cookies – think you need it? Maybe better with money?

Test tasks for juniors and how to solve them

Often there are test ones, especially for beginners. A junior test is a good way to understand how a candidate thinks and what he does in a situation where the answer is not on the surface. It’s okay if the candidate doesn’t know something. It’s scary if he gets scared or doesn’t try to find out.

The test task is sometimes written directly in the vacancy, sometimes they are offered to be completed right at the interview, but they can also be given after the first interview to do it at home.

Often these are puzzles like “what happens when you execute the following code.” In such cases, the problem is not in the code itself. Such tasks are quite simple, the catch may be that there are typos in the conditions that will lead to a code error, and you need to find them. Or the trick is that some variable may not be defined in the specified scope, which can also lead to an error. Here are a few examples found by searching that you can practice on.

  1. What will the execution of the code lead to:

 <script>
    const myarray = [0, 1, 2, 4, 6, 19, 25];
    const [myconst] = myarray;
    console.log(myconst);
    </script>

Answer: object arguments, which is used inside the myfunc function, is an array containing the arguments passed to the function (it’s easy to guess from its name). As a result of executing this code, 123 will appear in the console. In the function body, the value of the second argument (y) is replaced, so its value will become 123.

  1. What will the execution of the code lead to:

<script>
    function person(firstName, lastName) {
      function printPerson() {
        return firstName + " " + lastName;
      }
      console.log( "Hi, " + printPerson() );
    }
    person('Petr', 'Ivanov')
    console.log( "Bye, " + printPerson() );
</script>

Answer: here in the second line for myconst produced destructuring assignment. This means that we can take a number of variables at once and assign them the values ​​of some array. In this case, we have one argument, and as a result, the value of the first argument of the myarray array, that is, 0, will be displayed in the console.

You can independently add other variables to the left side of the assignment and see what values ​​​​they will be assigned to (spoiler – these will be the values ​​​​of the following array elements).

3. What will the execution of the code lead to:

<script>
    function person(firstName, lastName) {
      function printPerson() {
        return firstName + " " + lastName;
      }
      console.log( "Hi, " + printPerson() );
    }
    person('Petr', 'Ivanov')
    console.log( "Bye, " + printPerson() );
</script>

Answer: first, the console will display the string Hi, Petr Ivanov. Next, the execution of the person () function is completed, but the restless coder decided to call a function that is defined inside another function, but is not visible from the outside. Therefore, on the second line, he will naturally receive an error that occurs when accessing a non-existent variable.
Uncaught ReferenceError: printPerson is not defined

There are also questions that make you remember how variables of different types behave in different circumstances.

  1. What happens when the code is executed:

<script>
console.log( 1 / 0 );
</script>

Answer: Infinity will be displayed (infinity is a special value that is greater than any number).

2. What is the difference between null and undefined?

<script>
    let param;
    console.log(param)  // выведется undefined
</script>

Null is a special value that means “empty” or “value unknown”.

<script>
    let param = null;
    console.log(param)  // выведется undefined
</script>
  1. What happens when the code is executed:

<script>
    console.log(false == undefined);
    console.log(false == null);
</script>

Answer: False will be displayed twice in the console. The == sign tests for equality, but not identity, of types.

Separately, there may be questions about postponing the execution of functions.

  1. What happens when the code runs (according to rumors, such questions are asked during an interview at Google or Amazon):

<script>
    const arr = [10, 12, 15, 21];
    for (var i = 0; i < arr.length; i++) {
      setTimeout(function() {
        console.log('Index: ' + i + ', element: ' + arr[i]);
      }, 3000);
    }
</script>

Answer: The same line is displayed four times.

Index: 4, element: undefined

This will happen because there are 4 steps in the cycle, at each step there is postponement functions for 3 seconds. When it’s time to execute the function, the value of i will be equal to 4 (that’s how it became at the exit from the loop). Accordingly, the array element arr with this index is not defined, so the value undefined will be specified. And so 4 times! 2. What happens if we replace setTimeout with setInterval in the previous example?
Answer: everything is the same, but these 4 lines will be displayed again every 3 seconds. Since we are talking about Javascript, we cannot help but recall tasks like “which script in the code will load faster”:

<script src="https://habr.com/ru/company/netologyru/blog/667520/script_0.js"></script> 
<script async src="https://habr.com/ru/company/netologyru/blog/667520/script_1.js"></script>
<script defer src="https://habr.com/ru/company/netologyru/blog/667520/script_N.js"></script> 

Answer: here you should pay attention to the async, defer attributes. As soon as it comes to this script tag on page load, the system must first load and execute it. If there is an async attribute, then whoever got up earlier, that and slippers, that is, which script is loaded earlier, that one will work. As for defer, such scripts humbly wait for the entire page to load and work out in the order they are located in the document.

Undoubtedly, posting the test solution on Github with a link to the repository will be a big plus. Regardless of what technology knowledge is being tested. It is very good not only to know what VCS (Version Control Systems, version control systems) can be, but also to be able to execute basic commands: take a branch from the repository, create a new branch, make a commit, send it to the repository, resolve conflicts. At least on the fingers to explain what a conflict is and how it manifests itself. Also, working with the command line should not terrify a person. All of these fancy front-end builders require command-line work. Typically, tests are not paid. I met a paid test one once, at that moment it turned out to be very useful. I still think about how I would work there, but I chose another employer.

There was another case when, as a test, they asked me to make a project and send a link to the repository, but they did not promise payment. This is a common scam, as you can find out on Google, but an inner voice screamed about it to me from the very beginning. Be careful, it can be offensive.

How to prepare for an interview

Obviously – repeat basics and be prepared for the fact that there will be many, many more interviews in your life. Even if it went badly, you’ll know what to study and where to catch up.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *