r/learnjavascript • u/Green_Ad_6086 • Aug 16 '26
Strange result: null vs 0
Strange result: null vs 0
An incomparable undefined
Hi, can anyone explain this? I read the explanation, but I still don't understand it. I'm trying to understand it without using AI
6
Upvotes
View all comments
5
u/defaultguy_001 Aug 16 '26 edited Aug 16 '26
First u need to understand that type coercion (automatic type upgrade) happens when you use relational (>, <, >=, <=) or loose equality (==, !=) operators. Type coercion doesn't happen with strict equality (===, !===) operators. So it's recommended to use strict equality everywhere.