Expand Minimize

Disallow usage of NaN directly

Quote from ESLint 'In JavaScript, NaN is a special value of the Number type. It's used to represent any of the "not-a-number" values represented by the double-precision 64-bit format as specified by the IEEE Standard for Binary Floating-Point Arithmetic. NaN has the unique property of not being equal to anything, including itself. That is to say, that the condition NaN !== NaN evaluates to true.'

CheckId SPC018908
TypeName DisallowUseOfNaN
Severity CriticalError
Type JavaScriptFile

Bad Practice

if(foo === NaN) {
  return false;

Good Practice
if(isNaN(foo)) {
  return false;

Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.