In javascript
parseInt(null)returns a NaNparseNumber(null)also returns aNaN
parseInt(null)
NaN
parseNumber(null)
isNaN('abcd')returns truebecause "abcd" is certainly not a number,isNaN(5)returnsfalse
isNaN('abcd')
true
isNaN(5)
false
but strange
isNaN(null)returns falsethat is odd, as this is a number, but, as we saw in parseNumber, it can be seen asNaN
isNaN(null)
parseNumber
There seems to be an inconsistency between how the zero is scanned parseInt, and through isNaNit it sees it as NaN, and the other sees it as Number. Why are they incompatible?
parseInt
isNaN
The first thing that happens in isNaN()is that the argument is forced to a number. That is, as if the function looked like this:
isNaN()
function isNaN(n) { n = +n; // ... }
null , 0. NaN.
null
0
isNaN , , ; , . , , - , , - NaN.
Number.isNaN(), . , , null NaN.
Number.isNaN()
Source: https://habr.com/ru/post/1692393/More articles:Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Oracle 8 JDK Π½Π° Ubuntu - javaMerge rows of a 2d array if at least one value is equal - pythonTrying to use two separate instances of getline () to populate two separate vectors - c ++Is it possible to return the first non-empty value for different types of Java using options? - javaIs an atomic quantitative group the same as a quantitative atomic group? - regexF # Fake tries to create a Xamarin.iOS binding with the error "btouch-native.exe is not" - xamarinWhat does this mean in c? brackets inside braces - cOffer a top-level service or several service workers in the same domain? - service-workerSplit string with two special characters - javaPython: convert first search depth to first search width for all list combinations - pythonAll Articles