10 examples of 'mdn tofixed' in JavaScript

Every line of 'mdn tofixed' 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
62function toFixed(number, fractionDigits) {
63 return parseFloat(Number(number).toFixed(fractionDigits));
64}
161function toFixed(a) {
162 if(a) {
163 return a.toFixed(2);
164 }
165}
80function toFixedDecimalString(num) {
81 return num.toFixed(6);
82}
45function strToFixed(str, dig) {
46 if(dig == undefined) {
47 dig = 5;
48 }
49 return str.replace(/(\d+\.\d+)/g, function(match) {
50 return parseFloat(match).toFixed(dig);
51 });
52}
86function formatNumber(x) {
87 return x.toFixed(2);
88}
32function toFixed(val, e) {
33 return parseFloat(val.toFixed(e), 10);
34}
118export function round1(num: number) {
119 if (+num.toPrecision(4) === (num | 0)) return num;
120 else return num.toPrecision(4);
121}
98setPrecision(num: number, precision: number): string {
99 return num.toFixed(precision);
100}
5export function round(
6 n: number,
7 precision: number = defaultPrecision,
8): number {
9 return +n.toFixed(precision)
10}
81function formatNumber(n) {
82 return (+n.toFixed(2)).toString().replace(/(\d)(?=(\d{3})+(?:\.|$))/g, '$1,');
83};

Related snippets