JavaScript Logic Challenges #140236
Replies: 5 comments
-
Since NaN is the only JavaScript value that is treated as unequal to itself, you can also test if a value is NaN by checking it for equality to itself:
|
Beta Was this translation helpful? Give feedback.
-
You can check if a variable is NaN in JavaScript without using the isNaN() function by using the fact that NaN is the only value in JavaScript that is not equal to itself function isReallyNaN(value) {
return value !== value;
}
console.log(isReallyNaN(NaN)); // true
console.log(isReallyNaN(123)); // false
console.log(isReallyNaN("string")); // false |
Beta Was this translation helpful? Give feedback.
-
Hey there! 👋 Thanks for posting in the GitHub Community, @maiidaothanhvu ! We're happy you're here. You are more likely to get a useful response if you are posting your question in the applicable category. The Accessibility category is a place for our community to discuss and provide feedback on the digital accessibility of GitHub products. Digital accessibility means that GitHub tools, and technologies, are designed and developed so that people with disabilities can use them. We’ve moved your post to our Programming Help 🧑💻 category, which is more appropriate for this type of discussion. Please review our guidelines about the Programming Help category for more information. |
Beta Was this translation helpful? Give feedback.
-
you can use |
Beta Was this translation helpful? Give feedback.
-
使用
|
Beta Was this translation helpful? Give feedback.
-
How can you check if a variable is NaN (Not-a-Number) in JavaScript without using the isNaN() function?
Beta Was this translation helpful? Give feedback.
All reactions