This has nothing to do with Angular, what you code essentially does is this -
const b = "12.00";
const abc = parseFloat(b);
From Mozilla docs -
The toFixed() method formats a number using fixed-point notation.
This method returns a string with fixed-point notation.
You have mentioned that you have the value "12.00" assigned to b
, if this is a string value then you need to parse it before calling toFixed()
like below -
const b = "12.00";
const parsedNum = Number.parseFloat("12.00");
const abc = parsedNum.toFixed(2); // This is essentially the same as the initial value of "b" i.e. "12.00", see if you really want to do this.
If it's a number, then just call the toFixed()
like below -
const c = 12.00;
const abc = c.toFixed(2); // "12.00"
Also, go through this question.