Number validation

This commit is contained in:
Angelos Chalaris
2017-12-07 02:25:29 +02:00
parent a9050ca220
commit accae7f71a
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,8 @@
### Validate number
Use `!isNaN` in combination with `parseFloat()` to check if the argument is a number.
Use `isFinite()` to check if the number is finite.
```js
var validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n);
```