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 the difference between == and === in JavaScript?

    === (strict equality) is true only if both values have the same type and the same value. == (loose equality) first converts the values to a common type and then compares, which gives surprising results like 0 == "" being true. Use === by default.

    BeginnerIn-depth3 min read
  2. Why does "5" + 3 give "53" but "5" - 3 give 2?

    The + operator does string concatenation if either side is a string, so 3 becomes "3". The -, * and / operators only work on numbers, so they convert "5" to 5 first.

    BeginnerQuick answer1 min read