Question :
A practical example of this statement is:
parseInt(50) > parseInt('a');
When performing this operation on a console, for example, the result is false
.
The actual code that brought me to this question looks like this:
variableB = parseInt(jQuery('some-element').html());
if(parseInt(variableA) > variableB)
// Faça isso.
else
// Faça outra coisa.
Sometimes some-element
will not be filled with anything at all, causing the value of variableB
to be NaN
. But as some-element
was not filled with anything, I would like it to be evaluated as if it had been filled with 0. That is, if variableA
is a positive greater than 0, the comparison should return true
.
Answer :
Based on the English SO question you ” copied ”
Edit –
Based on the English SO question you ” did there and here ”
NaN checks always give FALSE.
NaN is not greater than any number
NaN is not the same as any number
NaN is not less than any number
Only the Boolean check will be false.