tofixed code example
Example 1: javascript show 2 decimal places
var myNumber=12.2345;
var myNumberWithTwoDecimalPlaces=parseFloat(myNumber).toFixed(2); //12.23
Example 2: javascript round to 2 digits
var num = 2;
var roundedString = num.toFixed(2);// 2.00
Example 3: tofixed currency in js
(12345.67).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); // 12,345.67
Example 4: js toFixed
var a = 3.3445;
var c = a.toFixed(1); console.log(c); /* result ->*/ 3.3
var g = a.toFixed(4); console.log(g); /* result ->*/ 3.3445
var g = a.toFixed(7); console.log(g); /* result ->*/ 3.3445000
// ^ ^^^^^^^
/*Syntax ->*/ number.toFixed([digits])
// like Me ;D . My company : Rnad
Example 5: tofixed
//round number to 2 digits
var num = 5.56789;
var n = num.toFixed(2);