compare NaN in javascript if condititon
// 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 .......
}
function isNaN(x) {
return x !== x;
};
isNaN(NaN);//true
Also in JavaScript:
- js code to run hello world
- angularjs form validation on submit
- jquery on scroll down
- create server and connect to db and frontend
- fetch composition API in Vue3
- how to make a component reload in angular
- how to create a javascript hello world program with node.js
- how to remove key value pair from object js
- change array index position in javascript by up and down click
- Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string. javascript
- Material-ui wallet icon
- current month in javascript
- how to log something in the console. javascript
- jquery replace element
- game winner pop up in javascript
- settimeout jquery
- node.js version
- change elements class javascript
- string literals javascript
- js redirect to relative url
- jQuery - AJAX Introduction
- jquery if attribute
- string to JSONobject + android
- parsefloat