mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
40 lines
857 B
Markdown
40 lines
857 B
Markdown
---
|
||
date: 2020-09-23
|
||
id: adb898a3-6623-4bd5-92e6-408287d8cb31
|
||
title: JavaScript Number library
|
||
---
|
||
|
||
# ES6
|
||
|
||
## .EPSILON
|
||
|
||
Compares floating point numbers with a tolerance for rounding errors.
|
||
|
||
## .isInteger(num)
|
||
|
||
``` javascript
|
||
console.log(Number.isInteger(1.05)) // false
|
||
console.log(Number.isInteger(1)) // true
|
||
console.log(Number.isInteger(-3.1)) // false
|
||
console.log(Number.isInteger(-3)) // true
|
||
```
|
||
|
||
## .isNaN
|
||
|
||
Checks whether num is the value NaN. In contrast to the global function
|
||
isNaN(), it doesn’t coerce its argument to a number and is therefore
|
||
safer for non-numbers:
|
||
|
||
``` javascript
|
||
console.log(isNaN('???')) // true
|
||
console.log(Number.isNaN('???')) // false
|
||
```
|
||
|
||
## .isFinite
|
||
|
||
Determines whether the passed value is a finite number
|
||
|
||
``` javascript
|
||
console.log(Number.isFinite(Infinity)) // false
|
||
console.log(Number.isFinite(123)) // true
|
||
```
|