Key points to consider for a JavaScript interview
Having both attended and taken multiple interviews for the role of Front End Engineer, I am here sharing key points to consider for a JavaScript interview.
Along with my observation, I have taken inputs from many other senior UI engineers before writing this article.
Prologue
If you’re reading this then I am sure that you’re a front end engineer or aspiring to be one. With the advancement in web technologies, the front end has become really amazing and challenging.
Gone are the days when just having knowledge of DOM Manipulation was enough. Now, with TypeScript, ES6, etc, the front-end is as challenging as backend. It’s not just about what to display on the browser, but also how do you display it, how do you consume the data from backend and a lot of business logic to be performed.
So with these things in mind, let’s dive into the key points that an interviewer will look into while evaluating your code. Below is a list of points that I’ve created:
- Prefer Vanilla JavaScript :
For most of the interviews on the front end, the desired way is to use vanilla JS instead of frameworks and libraries. So, if not explicitly specified, do not use frameworks, stick with pure JavaScript, understanding of the basic concepts on JavaScript will be much preferred than frameworks and not otherwise.
2. Focus less on perfecting CSS (unless explicitly specified):
Yes, you read it correctly. With little time allotted during the interview, if you focus on perfecting CSS, then you might not get enough time for the actual implementation of the task. A fair looking UI with more working functionality will be fruitful than perfect but non-functional UI.
3. Break and Prioritise the task
It’s pretty obvious that the time you are given won’t be enough to complete the entire task, so you will have to prioritize the task. First, break the task into various functionalities and modules, then make a list based on the requirement.
4. Modularise the code
Break your functionality into small modules. Make the modules as simple and readable as possible, put necessary comments so that the person evaluating will be able to understand what the code does even in your absence.
5. Reuse of code
The main point I consider while evaluating is code reusability. If there is any block of code getting written again, that just leaves a bad impression on me. If you think that a certain chunk of code is going to be re-used, then separate it out and reuse it.
6. Scope (IIFE)
As you might be aware, JavaScript is notorious about the Global variable. So, to avoid creating any global variable even my mistake, make use of Immediately Invoked Function Expression for each module, and wrap your variables in the scope of the function. here is the link on IIFE.
7. Naming of variable and functions
Name your variables and functions appropriately. It does not matter if your variable and functions are verbose as long as it describes its purpose even without the comments. Don’t ever name variables as X or Y.
8. Data Structure to be used
Once you understand what it is being asked in the assignment, take some time to analyze how do you solve it, instead of immediately starting to code. Figure out what are the data structures you can use for it (try to stick with the ones you are familiar with). Some commonly used data structures by javascript developers are Array, Object, and Maps.
9. local/session storage
As a front end developer, you are expected to make good use of resources provided by the browser. So having good knowledge of local/session storage (and even indexedDB) and making use of them to cache the data will be an added advantage for you.
10. ES6
Last but not the least, familiarise yourself with ES6. It does not matter if you are not perfect in it, having used it just a little for self-learning and understanding the necessity of it will be enough to impress the interviewer.
With these points in mind, you can go ahead and rock in your interview.
Here are some additional things you might want to prepare for while going for an interview:
JavaScript
- Promises: callbacks, callback hell and alternative to promise
- Closure: Expect you to create a function on your own and explain it to the interviewer.
- Call, Bind, and Apply: It’s implementation and polyfill for it.
- Inheritance: learn more
- Prototype and Scope.
- Function Objects and this: link here
- Infinite argument problem with currying and closure: link here
CSS
- Box modal.
- Flexbox.
- Position property.
- Display property: diff between block and inline-block.
- Understanding of SCSS and LESS.
HTML
- New features in HTML5
- HTML API: learn more
- WebStorage API (local/session storage)
Hope that this will be helpful and beneficial to you.
Feel free to comment if you need any further suggestions or if you have any suggestions for me.
If you find this article useful, you can show your appreciation by clicking on the clap button. As the saying goes, ‘When we give cheerfully and accept gratefully, everyone is blessed’.
I’ve also written an article on one of the most common and tricky javascript interview questions.
Thanks to Avinash .P for suggestions.