JavaScript for placements: interview questions by topic
JavaScript questions reach placement rounds from two directions: web-development roles, where it is the job, and general screening tests, where it is one more language whose output you must predict. Either way the questions gather where JavaScript behaves unlike the languages students usually learn first — values converting between types on their own, variables that exist before their declaration, functions that remember the scope they were created in, and a this that depends on how a function is called.
Interviewers then move to the runtime: what the event loop does with a timer and a promise, what async and await really pause, and how arrays, objects and prototypes behave when you copy, sort or extend them. Modern syntax — destructuring, spread, optional chaining and ?? — is expected in answers, and older habits such as var and == get questioned.
The pages below take one topic each, with answers whose code has been run in Node.js, and one question exactly as the diagnostic asks it. The diagnostic draws from every JavaScript topic in the bank and names the ones to read first.
JavaScript topics, one page each
8 of the 8 JavaScript topics in the bank have a page so far; the diagnostic draws from all 8.
- JavaScript type coercion interview questions
JavaScript types and coercion as interviews test them: the eight types, == vs ===, falsy values, how + decides, NaN, object-to-primitive, float precision.
- JavaScript hoisting and scope interview questions
Hoisting and scope in JavaScript, as interviews test them: var vs let vs const, the temporal dead zone, function hoisting, the scope chain and strict mode.
- JavaScript closures interview questions
JavaScript closures as interviews test them: what a closure captures, the var-in-a-loop bug, private state, memoize, debounce, currying and memory leaks.
- JavaScript this keyword interview questions
The this keyword in JavaScript as interviews test it: the binding rules, lost this in callbacks, arrow functions, call, apply and bind, classes.
- JavaScript objects and prototypes interview questions
JavaScript objects and prototypes for interviews: references vs copies, the prototype chain, __proto__ vs prototype, classes, freeze vs seal, and getters.
- JavaScript array methods interview questions
JavaScript array methods for interviews: map, filter and reduce, sort's comparator, mutating vs copying methods, find vs filter, dedupe, flat, Array.from.
- JavaScript promises and async/await interview questions
Asynchronous JavaScript for interviews: the event loop, microtasks vs tasks, promise states, async/await, error handling, and Promise.all vs allSettled.
- ES6 and modern JavaScript interview questions
ES6+ JavaScript for interviews: spread and rest, destructuring defaults, ?? and ?., template literals, Map vs object, modules, generators, arrows.
One question, exactly as the diagnostic asks it
From the JavaScript bank — 30 questions across 8 topics. The answer is marked because this one is public; in a sitting you choose first, then see why each option is right or wrong.
What does this code print?
const bank = (function () { let balance = 100; return { deposit: (x) => (balance += x) }; })(); bank.deposit(50); console.log(bank.balance, bank.deposit(0));
- 1150 150
- 2100 150
- 3TypeError is thrown
- 4undefined 150correct
balance is a local variable of the immediately invoked function; the returned object has only a deposit property, so bank.balance is undefined. deposit closes over balance and updates it, so after deposit(50) the balance is 150, and deposit(0) returns 150. 150 150 and 100 150 assume balance is a property of bank. Reading a missing property returns undefined rather than throwing, so there is no TypeError. This is the module pattern: closures give JavaScript private state.
Measure it
Reading the answers tells you what’s true. A diagnostic tells you what you get wrong.
10 JavaScript questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.