Job preparationJavaScript
JavaScript interview questions and answers

var/let/const, closures, prototypes, async and the DOM — what a front-end role will certainly ask you.
For front-end roles, the JavaScript questions go deepest — and they concentrate in three places: scope, this, and asynchronous code.
Get those three straight and the rest is comparatively easy. The questions below are arranged that way, with DOM and event handling alongside.
The questions
What is the difference between var, let and const for declaring variables in JavaScript?
What to coverCover the differences in scoping, in redeclaration, and in hoisting.
What is a closure in JavaScript and how does it work?
What to coverA function defined inside another function, and its access to the outer scope.
What is the difference between an arrow function and a regular function in JavaScript?
What to coverThe behaviour of the this keyword, the arguments object, and the syntax.
What is a prototype in JavaScript and how is it used?
What to coverThe prototype chain, prototypal inheritance, and where you use them.
What is asynchronous programming in JavaScript and what approaches are there?
What to coverCallbacks, promises, and async/await.
What is DOM manipulation in JavaScript and how is it done?
What to coverMethods on the Document Object Model such as getElementById, querySelector and addEventListener.
What are event bubbling and event capturing in JavaScript?
What to coverThe phases of the event model, and how to stop an event with stopPropagation and preventDefault.
How do you make a deep copy and a shallow copy in JavaScript?
What to coverWhat separates the two, and the several ways of producing each.
What is the this keyword in JavaScript and how does it work?
What to coverHow this is bound by scope and calling context, and the call, apply and bind methods.
What is a constructor function in JavaScript and how does it relate to a class?
What to coverThe difference between ES5 and ES6 class syntax, and the role each plays.
What are higher-order functions? Give an example.
What to coverA higher-order function is one that takes another function as an argument, or returns a function, or both. It is possible in JavaScript because functions are ordinary values. The familiar examples are map, filter and reduce: in [1,2,3].map(n => n * 2), map is the higher-order function, because it is taking n => n * 2 as its argument.
Tips for this round
- Closures and this are where most candidates stall. Practise by writing the examples out by hand.
- On async, answer in order: callbacks, then promises, then async/await. It shows you know how it got here.
- Have an answer ready for why var is no longer used.