📜  比较 JavaScript 中的 NaN if condititon - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:52.533000             🧑  作者: Mango

代码示例2
// Use isNaN() 
// In javascript compare NaN direct alweys return false
let num1 = Number("Vishal");

// This code never work
if(num1 == NaN){  // Direct compare NaN alweys return false so use isNaN() function
  ....... Your Code .......
}  

// This code work
if(isNaN(num1){
  .........Your Code .......
}