This guide covers the essential JavaScript topics asked in technical interviews. Each section includes explanations, code examples, and the follow-up questions interviewers actually ask.
01 Topics Covered
02 The Topics
A closure is a function that remembers variables from its outer scope even after the outer function has finished executing.
function createCounter() {
let count = 0; // This variable is "closed over"
return function() {
count++;
return count;
};
}
const counter = createCounter();
console.log(counter()); // 1
console.log(counter()); // 2
console.log(counter()); // 3Key Points
- Functions retain access to outer scope variables
- Useful for data privacy and encapsulation
- Common in callbacks, event handlers, modules
- Can cause memory issues if not careful
Follow-up Question
How would you create private variables using closures?
03 Preparation Tips
Practice in a Real Environment
Use PlayCode to practice coding. Get comfortable with the editor, console, and debugging under time pressure.
Explain As You Code
Interviewers want to hear your thought process. Practice narrating your approach while coding, not just in your head.
Know the "Why"
Don't just memorize syntax. Understand WHY closures work, WHY the event loop exists, WHY we need Promises.
Handle Edge Cases
Always consider: null/undefined inputs, empty arrays, negative numbers, large inputs. Mention these even if you don't handle all of them.
04 FAQ
What JavaScript topics are asked in interviews?
Core topics include: closures, promises/async-await, the event loop, prototypes, scope/hoisting, ES6+ features, and practical challenges like implementing debounce or array methods. Companies also ask DOM manipulation and event handling.
Do I need to know TypeScript?
Many companies expect TypeScript knowledge, but core JavaScript concepts are still fundamental. If the job listing mentions TypeScript, prepare for it. Otherwise, strong JavaScript fundamentals are often sufficient. You can always learn TS on the job.
Algorithm questions or practical JavaScript?
It depends on the company. Startups often focus on practical JavaScript (build a feature, debug code). Larger companies may include algorithm questions. Prepare for both, but practical JavaScript is more commonly asked for frontend roles.
Should I memorize these code examples?
No. Understand the concepts and practice implementing them. You should be able to write debounce or deep clone from understanding, not memory. Interviewers can tell when code is memorized vs understood.
Practice JavaScript in PlayCode
Real JavaScript environment with console, npm packages, and instant feedback.
Start PracticingFree to use. No signup required.