10 examples of 'jquery string to number' in JavaScript

Every line of 'jquery 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
2740function toNumber (str) {
2741 return parseInt(str, 10)
2742}
5function toNumber(s: any): number {
6 return +s;
7}
1function number(input: string | number): number {
2 if (typeof input === 'string') {
3 return parseInt(input.replace(/^\D+/g, ''), 10);
4 }
5
6 return 0;
7}
42function getNumber (str) {
43 str = str.replace(/(invert)|(brightness)|(blur)|(contrast)|(grayscale)|(sepia)|(threshold)|(gamma)?\(/g, '').replace(')', '')
44 if (str.indexOf('%') !== -1) {
45 return Number(str.replace('%', '')) / 100
46 } else if (str.indexOf('px') !== -1) {
47 return Number(str.replace('px', ''))
48 } else {
49 return Number(str)
50 }
51}
8export function parseNumber(s) {
9 s = String(s).replace(/[^\d-.]/g, '').replace(/\.$/, '');
10 if (!s.match(NUMBER_RE)) { return null; }
11 return parseFloat(s, 10);
12}
12function makeNumber(v) {
13 return parseFloat(v.replace(/[$,]/g, ''), 10);
14}
6function Number(value) {
7 return +value;
8}
505function number(n) {
506 if (n instanceof tree.Dimension) {
507 return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
508 } else if (typeof(n) === 'number') {
509 return n;
510 } else {
511 throw {
512 error: "RuntimeError",
513 message: "color functions take numbers as parameters"
514 };
515 }
516}
39export function ToInt(stringOrFloatVal) { return parseInt(stringOrFloatVal); }
5export function toNumber(value: string): number {
6 return parseInt(value, 10);
7}

Related snippets