10 examples of 'angularjs convert string to number' in JavaScript

Every line of 'angularjs convert string to 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
50public parseNumber(value: string): number {
51 return this.getGlobalize().parseFloat(value, 10, dotvvm.culture);
52}
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

2740function toNumber (str) {
2741 return parseInt(str, 10)
2742}
5function toNumber(s: any): number {
6 return +s;
7}
55function typed(value) {
56
57 // is a string ( "asdf" )
58 if (/^".*"\s*$/.test(value)) {
59 return value.substring(1, value.length - 1);
60 }
61
62 if ((parseFloat(value) + '') === value) {
63 return parseFloat(value);
64 }
65
66 if (value === 'true' || value === 'false') {
67 return value === 'true';
68 }
69
70 throw new Error('Cannot infer type of value ' + value);
71}
101private convertInteger(num: Integer) {
102 if (neo4j.integer.inSafeRange(num)) {
103 return neo4j.integer.toNumber(num);
104 }
105 return neo4j.integer.toString(num);
106}
208function isNumeric(n) {
209 return !isNaN(parseFloat(n)) && isFinite(n);
210}
118function toNumber(value) {
119 return +value;
120}
73export function coerceToInteger(
74 num: number | string | undefined
75): number | undefined {
76 if (num === undefined) return undefined
77
78 const coerced = Number.parseInt(num.toString(), 10)
79 if (Number.isNaN(coerced)) return undefined
80
81 return coerced
82}
62function toNumber(value, defaultValue) {
63 const number = parseInt(value, 10);
64 if (isNaN(number)) {
65 return defaultValue;
66 }
67 return number;
68}
99var parseNumber = function parseNumber(string) {
100 return (string.match(numberAccept) || []).join('');
101};

Related snippets