How to Prepare for the JavaScript Interview

Brush up on your knowledge of variables, data types, functions, loops, conditionals, and objects.

How to Prepare for the JavaScript Interview

Preparing for an interview isn’t fun! In fact, it’s probably the least fun thing about being an engineer.

In fact, it’s something I tried to avoid for most of my career. But I had to face reality in 2019 when I got laid off suddenly.

I also had to work remotely at the time and there weren’t a ton of remote jobs available. I spent every day prepping for coding interviews. I always treat my job search like it’s my actual job! And that was quite a bit easier when you literally do not have an actual job and you have to pay rent in San Francisco next month!

I was able to find an incredible remote job that taught me so much. It completely changed the trajectory of my career and it was the first time where I felt I really deserved my senior title.

And now I want to help you crush your JavaScript coding interview.

Don’t skip the basics!

A JavaScript interview may include questions on HTML or CSS. Sure, an interviewer is not going to go in depth about HTML and CSS, but you want to feel comfortable at least being able to look at an element in the DOM for example! You don’t want to be caught unaware if someone asks you how to look something up in the DOM!

So… Brush up on your understanding of the Document Object Model (DOM) and its manipulation using JavaScript. 

Here’s a list of the basics before an interview!

HTML:

  • Basic structure of an HTML document
  • Understanding HTML tags and their purpose
  • Using attributes in HTML tags (id, class, etc)
  • Utilizing common HTML elements (div, p, a, img, etc)

CSS:

  • Basic CSS syntax and rules
  • Selectors (class, id, element, etc.)
  • Box model (margin, padding, border)
  • Stylesheets and linking
  • Responsive design with media queries

DOM:

  • Understanding the Document Object Model (DOM)
  • Accessing elements using JavaScript. (Just know how to debug well in the console!)
  • Modifying element properties and attributes
  • Event handling and DOM events
  • Traversing the DOM tree

And don’t forget about the JavaScript basics as well!

Review your JavaScript Basics

Start by revisiting the fundamentals of JavaScript..

Brush up on your knowledge of variables, data types, functions, loops, conditionals, and objects. Sometimes we write so much React that we forget the basics!

What if you’re asked in an interview to solve some simple JavaScript functions without a framework? Are you going to be able to do it? That’s what practice is for!

Here’s a list of the things you should review:

  • Variables and data types
  • Functions
  • Loops
  • Conditionals
  • Objects
  • Scoping and the 'this' keyword
  • Built-in functions (map, filter, reduce, etc.)
  • Closures
  • Promises
  • Async/await

And make sure you feel comfortable answering questions. For example, with the 'this' keyword, which refers to the object or function that invokes it, could you answer the questions below?

2. What is the difference between global scope and local scope? Provide some examples.

3. How does lexical scoping work in JavaScript? Can you describe its benefits?

4. What is the purpose of the 'let' and 'const' keywords introduced in ES6? How do they differ from 'var' in terms of scoping?

5. Discuss hoisting in JavaScript and how it can impact variable scope.

Make sure you are also comfortable in JavaScript's built-in functions, such as map, filter, and reduce, and familiar with concepts like closures, promises, and async/await. Review array methods and understand how to manipulate arrays effectively as well. Long story short, just be comfortable!

Here are a few concepts to review:

  • JavaScript built-in functions: map, filter, reduce, sort, forEach, find, findIndex, some, every, includes, concat, reverse, slice, splice
  • Concepts: closures, promises, async/await
  • Effective manipulation of arrays using array methods and operations such as push, pop, shift, unshift, join, indexOf, lastIndexOf, fill, flat, flatMap, reduceRight, keys, values, entries, copyWithin, from, etc.

Additionally, make sure you have a basic understanding of RESTful APIs, HTTP methods, and how to make asynchronous requests using JavaScript's Fetch API or Axios.

Which brings us to another concept to review.. Async JavaScript!

Don’t wait on your Asynchronous JavaScript prep!

Asynchronous programming questions might be asked in a JavaScript interview! And you don’t want to feel like you’re not solid on the concept.

Revise the concepts of callbacks, promises, and async/await for your interview. Even 15 minutes a few times a month can be helpful!

  • Understand how JavaScript's event loop works and be comfortable with handling asynchronous code effectively.
  • Practice writing asynchronous code using timers, AJAX, and the Fetch API.
  • Become familiar with different error handling mechanisms, such as try-catch blocks and error objects. Learn about JavaScript's built-in error types and how to handle them appropriately

Data Structures and Algorithms

JavaScript interviewers often assess candidates on their ability to solve complex problems. Familiarize yourself with data structures, like:

  • arrays
  • linked lists
  • stacks
  • queues
  • trees
  • graphs.

Here are a few questions you might see in a coding interview focused on JavaScript:

  • Explain the difference between push, pop, shift, and unshift methods for manipulating arrays.
  • How do you check if a variable is an array in JavaScript?
  • How can you remove duplicate elements from an array in JavaScript?
  • Explain what a linked list is and how it differs from an array.
  • What are the advantages and disadvantages of using a linked list compared to an array?
  • Describe the process of inserting a new node at the beginning of a linked list.
  • How can you find the length of a linked list in JavaScript?
  • How do you reverse a linked list in JavaScript?

Practice solving coding challenges on platforms like LeetCode and HackerRank to improve your skills for an interview. Once a week, can you turn Netflix off and do 1-2 questions? I think you can! Let’s be honest, you’ve already watched Grey’s Anatomy season 3.. Three times in fact.

And while you’re working on solving the interview questions, talk out loud! This will help you to feel comfortable explaining your thought process during the actual interview.

Pick a framework 

It’s pretty rare these days to go in for an interview and expect to not know some type of frontend framework and be able to solve problems with it.

Pick one framework like React, for example, and be extremely comfortable in writing components, debugging, and solving problems with it.

  • Review the fundamentals of React components and the most popular npm modules that might be used 
  • React Hooks for state management in functional components.
  • State and props management in React.
  • Be able to create reusable components.
  • Understanding of lifecycle methods, specifically componentDidMount and componentDidUpdate.
  • React Router for implementing routing - • Familiarity with controlled and uncontrolled components in forms.
  • Knowledge of key concepts such as conditional rendering, event handling, and list rendering. You’ll learn these in even just creating a side project!.
  • React DevTools for debugging React applications. Just add this to chrome and play around!  
  • State management libraries like Redux 
  • React best practices, performance optimization, and common pitfalls to avoid.

Testing 

Sometimes you might be expected to debug the bug in Javascript. At the bare minimum, you want to be able to read a Javascript test and feel comfortable at least with one testing framework.

If you don’t feel comfortable with testing, set up automated unit testing using frameworks like Jasmine, Mocha, or Jest in your own side project to learn. 

Remember, interviews also assess problem-solving, communication, and critical thinking skills, so be sure to showcase your thought process and explain your decisions clearly.

Randall Kanna

Engineer/Writer/Speaker

Senior Software Engineer at Trim with almost a decade of experience. Published O'Reilly Author. Ex Eventbrite, Pandora, Gumroad, Ticketfly.