I am wondering why undefined == undefined but NaN != NaN.
I am wondering why undefined == undefined but NaN != NaN .
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Because that’s how it is defined in both the Abstract Equality Comparison Algorithm, and the Strict Equality Comparison Algorithm.
If either operand to
==or===isNaN, it returnsfalse.Abstract
EDIT: The motivation for the unequal comparison as noted by @CMS is compliance with the IEEE 754 standard.
From the Wikipedia link provided in the comment below: