LESSON 13 OF 50

Compare two values strictly

Observe that === compares values without type conversion.

Official sourceECMAScript — equality operatorsReviewed: 2026-08-26
STEP 1 · LEARN

How it works

Strict equality returns true only when the types are compatible and the values are equal. The number 5 and the string “5” have different types.

Correct example
const same = 5 === '5';
console.log(same);

The strict comparison produces false.

Common mistake
const same = 5 == '5';
console.log(same);

Loose equality allows conversion and produces true in this case.

STEP 2 · APPLY

Your exercise

Declare same as the strict comparison between 5 and the string “5”.

STEP 3 · RUN

Write and run the code

script.jsJAVASCRIPT
Isolated consoleisolated
Preparing the runtime…
Run the code to see the result.
The draft stays only in this browser.Isolated QuickJS · no DOM, session or network
STEP 4 · CHECK

What needs to pass

0%not checked
  • same is declared with const.
  • The initializer uses the === operator.
  • The output is false.
Explain the solution logic

The === operator preserves the type difference, and the output confirms the result.