I was working on a specific requirement where in an input text can sometimes be wrongly formatted to contain alphabets other than digits.
If you notice, Number.isNaN always almost returns false and this is because this function should only be used to verify id the input is NaN datatype or not. This will not help us to verify - is an input a number only or does it have any non-digit contents.
The only time when Number.isNaN returns true is when the value fed to it is indeed an 'NaN'. If you want to verify if the input really has anything apart from a non-digit in it, we can do something like this.
Number.isNaN came into picture because == and === both fail to verify the conditional check for a variable against NaN.
If you notice, Number.isNaN always almost returns false and this is because this function should only be used to verify id the input is NaN datatype or not. This will not help us to verify - is an input a number only or does it have any non-digit contents.
The only time when Number.isNaN returns true is when the value fed to it is indeed an 'NaN'. If you want to verify if the input really has anything apart from a non-digit in it, we can do something like this.
Number.isNaN came into picture because == and === both fail to verify the conditional check for a variable against NaN.



