Interview Q&A / JavaScript

INTERVIEW Q&A · 71 QUESTIONS

JavaScript interview questions

Closures, the event loop, this, promises and the core language questions every frontend round asks.

  1. What is a closure in JavaScript?

    A closure is a function that remembers the variables from the place where it was created, even after that outer function has finished running.

    BeginnerIn-depth2 min read
  2. Write a function once(fn) that lets fn run only the first time it is called.

    Return a wrapper that keeps a called flag and the first result in a closure. On the first call, run fn and store the result; on later calls, return the stored result without running fn.

    BeginnerQuick answerCoding1 min read