Subjects › JavaScript

Types and coercion

What JavaScript does when the types do not match.

The idea

Coercion rules are learnable but not guessable. The practical takeaway is to use === and to convert explicitly; the rules are worth knowing mainly so you can read other people's code.

Lesson

No lesson built yet. The worked solutions below are the material it would be assembled from.

Questions (4)

Question Type Difficulty Drift Accuracy
What does typeof null return? mcq Easy -0.90 — — (0)
What is the value of '5' + 3 and '5' - 3 ? mcq Moderate -0.30 — — (0)
Which of these is true in JavaScript? mcq Moderate 0.40 — — (0)
Explain the difference between ?? and || when providing a default value, and give a case where choosing wr… short Hard 1.00 — — (0)