Created
September 19, 2019 21:27
-
-
Save djD-REK/2943df49900568cbc8f4e99a318e4ffd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(typeof 37) // "number" | |
| console.log(typeof 2.71828) // "number" | |
| console.log(typeof Math.E) // "number" | |
| console.log(typeof Infinity) // "number" | |
| // The typeof NaN is "number" even though NaN means "Not-A-Number": | |
| console.log(typeof NaN) // "number" | |
| // Calling Number explicitly is one way to parse a number: | |
| console.log(typeof Number(`1`)) // "number" | |
| // The parseInt and parseFloat functions are other ways to parse: | |
| console.log(typeof parseInt(`100`)) // "number" | |
| console.log(typeof parseFloat(`100.01`)) // "number" | |
| // Parse failures lead to NaN, and NaN poisons other math: | |
| console.log(typeof (2 * parseInt(`invalid`))) // "number" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment