1.

How to delay a JavaScript function call using JavaScript?

Answer»

To check whether a value entered is a NaN or not, use the Number.isNaN() method. This method returns true if the value is not a number, else false is RETURNED.

Let’s say the following is our value:

VAR a = 'z';

To check whether it is a number or not, use isNaN() method: 

isNaN(a);

The following is an example that returns true i.e. not a number: 

&LT;!DOCTYPE html&GT; <html> <body> <SCRIPT>     var a = 'z';     document.write(isNaN(a)); </script> </body> </html>

The output: 

true

Let us see another example: 

<!DOCTYPE html> <html> <body> <script>     var a = 0/0;     document.write(isNaN(a)); </script> </body> </html>

The output generates True since 0/0 is not a legal number:

True

Let us see another example that is a number. Therefore, false is returned: 

<!DOCTYPE html> <html> <body> <script>     var a = 50;     document.write(isNaN(a)); </script> </body> </html>

The output:

false


Discussion

No Comment Found