Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Handle the two edge cases where === gives incorrect results: NaN should equal NaN (use Number.isNaN to detect both), and -0 should not equal +0 (use 1/x to distinguish via Infinity signs). For all other values, fall through to strict equality.
The 1/x trick exploits the fact that 1/+0 is Infinity while 1/-0 is -Infinity, distinguishing the two zeros that === considers equal. Number.isNaN correctly identifies NaN which === rejects.
Updated Feb 2026