mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-07-13 21:15:35 +08:00
feat(curriculum): added a short explanation on ES6 for isNan lesson (#62592)
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
parent
a8bbe93fa6
commit
79c06257ac
@ -43,7 +43,7 @@ console.log(isNaN("blabla")); // true: "blabla" is not a number
|
||||
|
||||
As you can see, `isNaN()` first attempts to convert the parameter to a number. If it can't be converted, it returns `true`. This behavior can lead to some surprising results, especially when dealing with strings that can be coerced into numbers.
|
||||
|
||||
Due to these potential inconsistencies, ES6 introduced `Number.isNaN()`. This method does not attempt to convert the parameter to a number before testing. It only returns `true` if the value is exactly `NaN`:
|
||||
Due to these potential inconsistencies, ES6 (the sixth edition of JavaScript, released in 2015) introduced `Number.isNaN()`. This method does not attempt to convert the parameter to a number before testing. It only returns `true` if the value is exactly `NaN`:
|
||||
|
||||
```js
|
||||
console.log(Number.isNaN(NaN)); // true
|
||||
|
||||
Loading…
Reference in New Issue
Block a user