Compare values safely

Compare values safely in JavaScript — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
I need to check whether user input equals a stored config value without misclassifying 0, '', null…
I need to check whether user input equals a stored config value without misclassifying 0, '', null or NaN. Compare the two values so the result is true only when they are the same value and same type, not just loosely equal. If the values are objects or arrays, treat them as unequal unless they reference the exact same object. Use concise code I can paste into a validation function used on form submit.

Improve — make it easier to accept

+
Before I add this comparison into the login flow, make the outcome easy for reviewers to see. Put…
Before I add this comparison into the login flow, make the outcome easy for reviewers to see. Put the strict equality result at the top of the snippet, comment why === is chosen over ==, and flag the cases that commonly confuse reviewers: 0 versus '0', null versus undefined, NaN behaviour. Make the code two or three lines max and readable for a junior dev.

Decide — diagnose the stuck moment

+
I just used == to compare an input value and a stored preference and it returned true when the…

I compared values and got unexpected true from a loose check

I just used == to compare an input value and a stored preference and it returned true when the input was an empty string and the preference was 0. Priya on QA will call this a bug because empty string isn’t a valid numeric choice. I’m unsure whether to change all comparisons to === or adjust upstream parsing. What’s the likely cause and the safest next step for production code?

Become — change the pattern

+
Across several projects we keep patching bugs where == accepts unintended inputs: form fields,…

Loose equality causes subtle bugs across code reviews

Across several projects we keep patching bugs where == accepts unintended inputs: form fields, query params, feature flags. It eats review time and surfaces in production as wrong behaviour. Which habit change will stop this recurring issue: always coerce inputs first, always use strict equality, add a lint rule, or a combination? Recommend the single best practice and how to make it stick in our team.

Next to this one

Other programming language work people do in JavaScript.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.