Language-Specific Prep
JavaScript Coding Interview Questions (2026)
JavaScript is increasingly accepted in coding interviews, especially at startups, frontend-focused roles, and companies with JavaScript-heavy stacks. Its flexibility, first-class functions, and dynamic typing let you write solutions quickly. While not as common as Python or Java at FAANG, it is a solid choice for web-focused roles.
Why JavaScript for Coding Interviews
Strengths
- ✓Dynamic typing — no type declarations, write faster
- ✓First-class functions — closures and callbacks are natural
- ✓Map, Set, and WeakMap for hash-based lookups
- ✓Array methods: map, filter, reduce, find, sort with comparators
- ✓Template literals for clean string building
- ✓Spread operator and destructuring for clean code
Watch Out For
- ⚠No built-in priority queue — must implement or use a sorted insertion
- ⚠Number type is always 64-bit float — no int/long distinction
- ⚠Array.sort() sorts lexicographically by default — must pass comparator
- ⚠No tuples — use arrays or objects
- ⚠0.1 + 0.2 !== 0.3 — floating point quirks
- ⚠var vs let vs const scoping rules can confuse under pressure
Must-Know JavaScript Features for Interviews
Map and Set — O(1) lookup (use Map over plain objects for non-string keys)
Array.sort((a,b) => a - b) — numeric sorting
Array.prototype.reduce — accumulating results
JSON.parse(JSON.stringify(obj)) — deep cloning
Destructuring: const [a, b] = arr; const {x, y} = obj;
Spread operator: [...arr], {...obj}
Template literals: `Hello ${name}`
Optional chaining: obj?.prop?.nested
Nullish coalescing: val ?? "default"
BigInt — large integers beyond Number.MAX_SAFE_INTEGER
JavaScript Interview Tips
Use Map instead of plain objects for hash maps
Map preserves insertion order, supports any key type (not just strings), and has a reliable size property. Use map.set(key, val), map.get(key), map.has(key), map.delete(key). For frequency counters: const freq = new Map(); freq.set(x, (freq.get(x) || 0) + 1).
Always pass a comparator to Array.sort()
arr.sort() sorts lexicographically — [10, 9, 8].sort() gives [10, 8, 9]. Always use arr.sort((a, b) => a - b) for ascending numeric sort, or arr.sort((a, b) => b - a) for descending.
Use a MinHeap class for priority queue problems
JavaScript has no built-in priority queue. Create a simple MinHeap class with push(val), pop(), and peek() methods using an array and bubble-up/bubble-down logic. This is 30 lines of code and covers all heap problems.
Deep clone with structuredClone()
For deep cloning objects or arrays, use structuredClone(obj) (modern browsers/Node 17+). The old JSON.parse(JSON.stringify(obj)) approach fails with undefined, functions, Dates, and circular references. structuredClone handles all of these.
Use BigInt for large integer arithmetic
JavaScript numbers are 64-bit floats — MAX_SAFE_INTEGER is 2^53 - 1. For problems involving very large integers, use BigInt: let big = BigInt(123); or 123n. Note: BigInt and Number cannot be mixed in arithmetic without explicit conversion.
JavaScript Coding Interview Problems by Pattern
Sliding Window
(27)Two Pointers
(51)Binary Search
(34)Prefix Sum
(9)| Subarray Sum Equals K | Medium | JS → |
| Product of Array Except Self | Medium | JS → |
| Range Sum Query - Immutable | Easy | JS → |
| Contiguous Array | Medium | JS → |
| Find Pivot Index | Easy | JS → |
| Running Sum of 1D Array | Easy | JS → |
| Minimum Average Difference | Medium | JS → |
| Max Chunks To Make Sorted | Medium | JS → |
| Max Chunks To Make Sorted II | Medium | JS → |
Hash Map / Set
(12)| Two Sum | Easy | JS → |
| Group Anagrams | Medium | JS → |
| Top K Frequent Elements | Medium | JS → |
| Valid Anagram | Easy | JS → |
| Longest Consecutive Sequence | Medium | JS → |
| Contains Duplicate | Easy | JS → |
| Word Pattern | Easy | JS → |
| Isomorphic Strings | Easy | JS → |
| LRU Cache | Medium | JS → |
| 4Sum II | Medium | JS → |
| Number of Good Pairs | Easy | JS → |
| Subarray Sum Divisible by K | Medium | JS → |
Stack
(22)| Valid Parentheses | Easy | JS → |
| Min Stack | Medium | JS → |
| Evaluate Reverse Polish Notation | Medium | JS → |
| Daily Temperatures | Medium | JS → |
| Decode String | Medium | JS → |
| Asteroid Collision | Medium | JS → |
| Remove K Digits | Medium | JS → |
| Car Fleet | Medium | JS → |
| Basic Calculator II | Medium | JS → |
| Simplify Path | Medium | JS → |
| Next Largest Element to Right | Medium | JS → |
| Next Largest Element to Left | Medium | JS → |
| Next Smallest Element to Left | Medium | JS → |
| Next Smallest Element to Right | Medium | JS → |
| Maximum Area Rectangle in Binary Matrix | Medium | JS → |
| Minimum Element in Stack with Extra Space | Medium | JS → |
| Minimum Element in Stack in O | Medium | JS → |
| Implement Queue using Stack | Medium | JS → |
| Implement Stack using Queues | Medium | JS → |
| Remove All Occurrences of a Substring | Medium | JS → |
| Minimum invalid parentheses to remove to make valid parentheses | Easy | JS → |
| Minimum Add to Make Parentheses Valid | Medium | JS → |
Queue / BFS
(10)| Number of Islands | Medium | JS → |
| Rotting Oranges | Medium | JS → |
| Binary Tree Level Order Traversal | Medium | JS → |
| Word Ladder | Hard | JS → |
| 01 Matrix | Medium | JS → |
| Walls and Gates | Medium | JS → |
| Shortest Path in Binary Matrix | Medium | JS → |
| Open the Lock | Medium | JS → |
| Minimum Genetic Mutation | Medium | JS → |
| Jump Game III | Medium | JS → |
Heap / Priority Queue
(14)| Kth Largest Element in an Array | Medium | JS → |
| Find Median from Data Stream | Hard | JS → |
| Task Scheduler | Medium | JS → |
| Merge K Sorted Lists | Hard | JS → |
| K Closest Points to Origin | Medium | JS → |
| Reorganize String | Medium | JS → |
| Top K Frequent Words | Medium | JS → |
| Find K Pairs with Smallest Sums | Medium | JS → |
| Minimum Cost to Connect Sticks | Medium | JS → |
| Sort an Almost Sorted Array | Medium | JS → |
| Find K Closest Elements | Medium | JS → |
| Connect Ropes to Minimize the Cost | Medium | JS → |
| The sum of Elements between k1 smallest and k2 smallest numbers | Medium | JS → |
| Kth Largest Element in a Stream | Medium | JS → |
Linked List
(24)| Reverse Linked List | Easy | JS → |
| Linked List Cycle | Easy | JS → |
| Merge Two Sorted Lists | Easy | JS → |
| Reorder List | Medium | JS → |
| Add Two Numbers | Medium | JS → |
| Remove Nth Node From End of List | Medium | JS → |
| Copy List with Random Pointer | Medium | JS → |
| Palindrome Linked List | Easy | JS → |
| Swap Nodes in Pairs | Medium | JS → |
| Rotate List | Medium | JS → |
| Reverse Nodes in k-Group | Hard | JS → |
| Find the intersection of two linked lists | Medium | JS → |
| Middle of the Linked List | Easy | JS → |
| Add Two Numbers Represented in Linked List | Medium | JS → |
| Linked List Cycle II | Medium | JS → |
| Remove Duplicates from Sorted List | Easy | JS → |
| Remove Duplicates from Sorted List - II | Easy | JS → |
| Add Two Numbers II | Medium | JS → |
| Odd Even Linked List | Medium | JS → |
| Reverse a Linked List in groups of given size k | Medium | JS → |
| Reverse Linked List II | Medium | JS → |
| Convert Binary Number in a Linked List to Integer | Medium | JS → |
| Partition List | Medium | JS → |
| Sort List | Medium | JS → |
Trees / DFS
(18)| Invert Binary Tree | Easy | JS → |
| Maximum Depth of Binary Tree | Easy | JS → |
| Validate Binary Search Tree | Medium | JS → |
| Lowest Common Ancestor of a BST | Medium | JS → |
| Binary Tree Maximum Path Sum | Hard | JS → |
| Serialize and Deserialize Binary Tree | Hard | JS → |
| Diameter of Binary Tree | Easy | JS → |
| Symmetric Tree | Easy | JS → |
| Binary Tree Right Side View | Medium | JS → |
| Kth Smallest Element in a BST | Medium | JS → |
| Construct Binary Tree from Preorder and Inorder Traversal | Medium | JS → |
| Path Sum II | Medium | JS → |
| Count Good Nodes in Binary Tree | Medium | JS → |
| Flatten Binary Tree to Linked List | Medium | JS → |
| Sum Root to Leaf Numbers | Medium | JS → |
| Populating Next Right Pointers in Each Node | Medium | JS → |
| Same Tree | Easy | JS → |
| Subtree of Another Tree | Easy | JS → |
Graphs
(10)| Clone Graph | Medium | JS → |
| Pacific Atlantic Water Flow | Medium | JS → |
| Number of Connected Components in Undirected Graph | Medium | JS → |
| Surrounded Regions | Medium | JS → |
| Minimum Height Trees | Medium | JS → |
| Network Delay Time | Medium | JS → |
| Find Eventual Safe States | Medium | JS → |
| All Paths From Source to Target | Medium | JS → |
| Cheapest Flights Within K Stops | Medium | JS → |
| Graph Valid Tree | Medium | JS → |
Dynamic Programming
(26)| Climbing Stairs | Easy | JS → |
| House Robber | Medium | JS → |
| Coin Change | Medium | JS → |
| Longest Increasing Subsequence | Medium | JS → |
| Longest Common Subsequence | Medium | JS → |
| Word Break | Medium | JS → |
| Edit Distance | Hard | JS → |
| Unique Paths | Medium | JS → |
| Maximum Subarray | Medium | JS → |
| Decode Ways | Medium | JS → |
| Min Cost Climbing Stairs | Easy | JS → |
| House Robber II | Medium | JS → |
| Partition Equal Subset Sum | Medium | JS → |
| Target Sum | Medium | JS → |
| Best Time to Buy and Sell Stock | Easy | JS → |
| Palindromic Substrings | Medium | JS → |
| Longest Palindromic Substring | Medium | JS → |
| Best Time to Buy and Sell Stock with Cooldown | Medium | JS → |
| Maximum Product Subarray | Medium | JS → |
| Triangle | Medium | JS → |
| Minimum Path Sum | Medium | JS → |
| Perfect Squares | Medium | JS → |
| Regular Expression Matching | Hard | JS → |
| Interleaving String | Medium | JS → |
| Best Time to Buy and Sell Stock with Transaction Fee | Medium | JS → |
| Integer Break | Medium | JS → |
Greedy
(8)| Jump Game | Medium | JS → |
| Jump Game II | Medium | JS → |
| Gas Station | Medium | JS → |
| Non-overlapping Intervals | Medium | JS → |
| Meeting Rooms II | Medium | JS → |
| Queue Reconstruction by Height | Medium | JS → |
| Minimum Number of Arrows to Burst Balloons | Medium | JS → |
| Candy | Hard | JS → |
Backtracking
(14)| Permutations | Medium | JS → |
| Subsets | Medium | JS → |
| Combination Sum | Medium | JS → |
| Word Search | Medium | JS → |
| Letter Combinations of a Phone Number | Medium | JS → |
| Generate Parentheses | Medium | JS → |
| N-Queens | Hard | JS → |
| Palindrome Partitioning | Medium | JS → |
| Combination Sum II | Medium | JS → |
| Subsets II | Medium | JS → |
| Next Permutation | Medium | JS → |
| Find all permutations of a string | Medium | JS → |
| Find all permutations of a given string without duplicates | Medium | JS → |
| Longest Valid Parentheses | Easy | JS → |
Trie
(5)| Implement Trie (Prefix Tree) | Medium | JS → |
| Design Add and Search Words Data Structure | Medium | JS → |
| Word Search II | Hard | JS → |
| Longest Word in Dictionary | Medium | JS → |
| Replace Words | Medium | JS → |
Union Find
(6)| Redundant Connection | Medium | JS → |
| Accounts Merge | Medium | JS → |
| Number of Provinces | Medium | JS → |
| Satisfiability of Equality Equations | Medium | JS → |
| Swim in Rising Water | Hard | JS → |
| Most Stones Removed with Same Row or Column | Medium | JS → |
Monotonic Stack
(7)| Largest Rectangle in Histogram | Hard | JS → |
| Next Greater Element I | Easy | JS → |
| Sum of Subarray Minimums | Medium | JS → |
| Online Stock Span | Medium | JS → |
| 132 Pattern | Medium | JS → |
| Remove Duplicate Letters | Medium | JS → |
| Stock Span Problem | Medium | JS → |
Topological Sort
(5)| Course Schedule | Medium | JS → |
| Course Schedule II | Medium | JS → |
| Parallel Courses | Medium | JS → |
| Sequence Reconstruction | Medium | JS → |
| Alien Dictionary | Hard | JS → |
Bit Manipulation
(8)| Single Number | Easy | JS → |
| Missing Number | Easy | JS → |
| Counting Bits | Easy | JS → |
| Number of 1 Bits | Easy | JS → |
| Reverse Bits | Easy | JS → |
| Sum of Two Integers | Medium | JS → |
| Single Number II | Medium | JS → |
| Power of Two | Easy | JS → |
Intervals
(4)| Merge Intervals | Medium | JS → |
| Insert Interval | Medium | JS → |
| Minimum Interval to Include Each Query | Hard | JS → |
| Meeting Rooms | Easy | JS → |
Matrix
(7)| Rotate Image | Medium | JS → |
| Spiral Matrix | Medium | JS → |
| Set Matrix Zeroes | Medium | JS → |
| Maximal Square | Medium | JS → |
| Game of Life | Medium | JS → |
| Search a 2D Matrix II | Medium | JS → |
| Count Negative Numbers in a Sorted Matrix | Easy | JS → |
Frequently Asked Questions
Can I use JavaScript for coding interviews at FAANG?
What JavaScript features are most useful for coding interviews?
How do I implement a min-heap in JavaScript?
Why does [1,2,3].sort() not work as expected in JavaScript?
Ready to start practicing?
Browse all problems with JavaScript solutions, or follow the pattern-based roadmap.