10 examples of 'javascript check if string is number' in JavaScript

Every line of 'javascript check if string is number' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
13public isNumber(value: any) {
14 return typeof value === 'number' && isFinite(value);
15}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

93function isNumber( object ) {
94
95 return typeof object == 'number';
96}
62function isNumber(value) {
63 var patrn = /^(-)?\d+(\.\d+)?$/;
64 if (patrn.exec(value) == null || value == "") {
65 return false
66 } else {
67 return true
68 }
69}
17export function isNumber(number) {
18 return typeof number === 'number';
19}
15function number(value) {
16 return typeof value === 'number' || value instanceof Number;
17}
11function isNumber(value) {
12 return (value instanceof Number) || (typeof value == 'number');
13}
1function containsNumber(str) {
2 return !!str.match(/\d/g);
3}
40export function isNumber(num) {
41 return typeof num === 'number' && !Number.isNaN(num);
42}
11function isNumber(value) {
12 return typeof value == "number";
13}
1296function isNumber(value) {
1297 return typeof value == 'number' || toString.call(value) == numberClass;
1298}

Related snippets