Interview Q&A / JavaScript
JavaScript interview questions
Closures, the event loop, this, promises and the core language questions every frontend round asks.
Prefer rapid revision? Practise JavaScript short interview answers →
- What is NaN, and how do you check whether a value is NaN?
NaN means 'Not a Number' and comes from failed numeric operations like Number("abc"). It is the only value not equal to itself, so use Number.isNaN(value), which avoids the coercion done by the older global isNaN.
BeginnerQuick answer1 min read - Why is 0.1 + 0.2 not equal to 0.3 in JavaScript?
Numbers are stored in binary floating point (IEEE 754), and 0.1 and 0.2 cannot be represented exactly in binary, so the sum is 0.30000000000000004. Compare with a small tolerance, or do money maths in whole paise.
IntermediateQuick answer1 min read