JavaScript Interview Questions
This guide covers a wide range of topics—from the fundamentals of JavaScript to
more advanced concepts and coding challenges.
1. JavaScript Fundamentals
JavaScript Basics
1. Primitive Types: What are the primitive data types in JavaScript?
2. Null vs. Undefined: Explain the difference between null and undefined.
3. The this Keyword: What is the purpose of the this keyword in JavaScript?
4. Variable Declarations: Describe the differences between var, let, and
const.
5. Hoisting: How does hoisting work in JavaScript?
6. Closures: Explain the concept of closures.
7. Event Loop: What is the event loop in JavaScript?
8. Equality Operators: Describe the differences between == and ===.
9. Bind Method: What is the purpose of the bind method in JavaScript?
[Link] Objects: Explain shallow copy versus deep copy.
JavaScript Functions
[Link] Functions: What is a callback function?
[Link] Hoisting: Explain the concept of function hoisting.
[Link] vs. Expressions: Describe the difference between function
declarations and function expressions.
[Link] Functions: What are arrow functions, and how do they differ from
regular functions?
[Link], call, bind: How do the apply, call, and bind methods work?
Objects and Arrays
[Link] Cloning: How would you clone an object in JavaScript?
[Link] Inheritance: Explain the concept of prototypal inheritance.
[Link](): What is the purpose of the [Link]() method?
[Link] Properties: How do you iterate over an object's properties?
[Link] Methods: What are the map, filter, and reduce methods used for?
[Link] vs. Splice: Explain the difference between slice and splice in arrays.
Asynchronous JavaScript
[Link]: What is a Promise in JavaScript?
[Link] Chaining: Explain the concept of promise chaining.
[Link]/Await: What is the async/await syntax, and how does it work?
[Link] Handling: How do you handle errors in asynchronous code?
[Link] API: What is the purpose of the fetch API?
DOM and Events
[Link] Delegation: Explain the concept of event delegation.
[Link] vs. HTML Document: How does the DOM differ from the HTML
document?
[Link]: What is the purpose of the addEventListener method?
[Link] vs. DOMContentLoaded: Describe the difference between the load
event and the DOMContentLoaded event.
ES6+ Features
[Link] Literals: What are template literals, and how do you use them?
[Link]: Explain destructuring in JavaScript.
[Link] & Rest: What is the purpose of the spread and rest operators?
[Link]: How do you use modules in JavaScript?
Advanced Concepts
[Link]: Explain the concept of memoization.
[Link] (Revisited): What is a closure, and how is it used? (May overlap with
earlier questions.)
[Link] Stack vs. Heap: Describe the differences between the call stack and the
heap.
[Link] Data Type: What is the significance of the Symbol data type?
[Link] Management: How does the JavaScript engine manage memory?
Frameworks & Libraries
[Link] DOM: Describe the virtual DOM and its purpose in front-end
frameworks.
[Link] Frameworks: What are the key features of React, Vue, or Angular?
Web Development Essentials
[Link] vs. HTTPS: Explain the difference between HTTP and HTTPS.
[Link] Options: How does local storage differ from session storage?
[Link]: What is CORS, and how do you handle it in JavaScript?
2. Problem-Solving & Advanced Questions
Scenario-Based Questions
● What is hoisting in JavaScript, and how does it work?
● What is the difference between let and var?
● What is the event loop, and what is its precedence?
● What is the difference between setTimeout and setInterval?
● Where would you use the rest operator?
● Have you used [Link]? How does it work?
● Explain shallow copy versus deep copy.
● What are closures? Provide examples.
● How do the map and reduce methods differ? What parameters do they
accept?
● What is the difference between a promise and a callback?
● Discuss various CSS position attributes you have used and their differences.
● What is Flexbox?
● Explain the difference between display: none and visibility:
hidden.
● What React Hooks have you used? What is the purpose of useCallback?
● What are class-based lifecycle methods in React?
● How would you implement componentDidMount, componentDidUpdate,
and componentWillUnmount in a functional component?
● What are pure components, and what is their purpose?
● What are higher-order components (HOCs)? Which ones have you used?
● Have you used the Context API?
● Given existing state management in React, why might one choose Redux, and
how does Redux work?
● What are middleware in Redux, and what is their purpose?
Additional JavaScript Questions
1. What is an arrow function?
2. What is a callback function?
3. What is a recursive function?
4. Write a function to find the first non-repeated character in a string.
Modern JavaScript (ES6+)
1. Name some features of ES6.
2. How do let and const differ from var? (Provide examples.)
3. Explain the concept of hoisting.
4. What is the purpose of const?
5. Can you add or remove elements from an array or object declared with
const? (e.g., const arr = [1,2,3,4,5])
6. Provide examples of the rest parameter and spread operator.
7. Is JavaScript single-threaded or multi-threaded? How does it handle
asynchronous activity?
8. What are closures? (Reinforce your earlier answer.)
9. What is function currying?
Performance & Optimization
● Site Performance:
○ How would you make a site faster?
○ Consider aspects like route splitting/module chunking (via Webpack),
asset caching, lazy loading, asynchronous resource loading, and
profiling tools (e.g., Google Lighthouse).
○ Explain the trade-offs in caching, minification, CDN usage, tree
shaking, and image optimization.
○ A strong answer starts with profiling to identify bottlenecks before
applying specific optimizations.
● Coding Challenge Scenario:
○ Typically involves fetching data from an API, displaying it, and
implementing filtering functionality.
○ Additional React-related questions might cover hooks, lifecycle
phases, performance optimization, and bundle size concerns.
Conceptual & Best-Practice Questions
● Explain your understanding of semantic versioning and why it’s important for
developer tools.
● What does 'use strict'; do when placed in a function? Why is it less
common in modern JavaScript?
● What is a closure in JavaScript? Provide an example.
● What happens when you call 'foo'.charAt(0)? Is there a difference
between const x = "taco"; and const x = new String("taco");?
● Explain JavaScript’s inheritance model.
● Name two programming paradigms that are important for JavaScript
developers.
● What is asynchronous programming, and what does it mean in JavaScript?
CSS and Browser Concepts
● CSS Units: Which unit do you prefer (px, em, rem, %, or pt) and why?
● CSS Specificity: What is specificity, how is it calculated, and why is it
important?
● CSS Layout: Provide a high-level overview of CSS layout principles.
Browser & Networking Fundamentals
● URL to Webpage: Describe in detail what happens when a person types a URL
into a browser until a webpage is displayed.
(This tests your understanding of DNS resolution, HTTP requests, browser
rendering, etc.)
3. Coding Challenges & Data Structures
Basic Algorithmic Challenges
1. Reverse a String: Write a function to reverse a string.
2. Factorial: Implement a function to calculate the factorial of a number.
3. Palindrome Check: Create a function to determine if a given string is a
palindrome.
4. FizzBuzz:
○ Print "Fizz" for multiples of 3, "Buzz" for multiples of 5, and "FizzBuzz"
for multiples of both.
5. Largest Number: Write a function to find the largest number in an array.
Arrays and Strings
6. Two Sum: Given an array of integers, find two numbers that add up to a
specific target.
7. Longest Substring: Find the length of the longest substring without repeating
characters.
8. Rotate Array: Rotate an array to the right by k steps.
9. Group Anagrams: Group an array of strings into anagrams.
[Link] Words: Reverse the words in a given string.
Advanced Arrays
[Link] Intervals: Merge overlapping intervals in an array.
[Link] Except Self: Calculate the product of an array except for the element
at each index.
Linked Lists
[Link] Linked List: Reverse a singly linked list.
[Link] Detection: Determine whether a linked list has a cycle.
Trees and Graphs
[Link] Tree Maximum Path Sum: Find the maximum path sum in a binary
tree.
[Link] Sort: Implement topological sorting for a directed acyclic graph.
[Link]-First Search (BFS): Traverse a graph using BFS.
[Link]-First Search (DFS): Traverse a graph using DFS.
Sorting and Searching
[Link] Search: Implement the binary search algorithm.
[Link] Sort: Implement the merge sort algorithm.
Dynamic Programming
[Link] Sequence: Implement a solution for calculating the nth Fibonacci
number using dynamic programming.
[Link] Increasing Subsequence: Find the length of the longest increasing
subsequence in an array.
Object-Oriented Programming
[Link] a Class: Create a class representing a basic entity with methods and
properties.
[Link]: Create a base class and a derived class to demonstrate
inheritance.
Advanced Concepts in Code
[Link]/Await: Write an asynchronous function using async/await to fetch
data.
[Link]: Chain promises to perform asynchronous operations sequentially.
[Link]: Optimize a recursive function using memoization.
[Link]: Implement a currying function.
[Link] Handling: Create a custom event handler.
[Link]: Implement a simple chat application using WebSockets.