When I call the toFixed() method on a decimal number literal like so:
var a = 67.678.toFixed(2);
console.log(a);
The result works and returns 67.68
However if I call the method on an integer - I get an error
var b = 67.toFixed(2);
console.log(b); // causes ERROR
Why is this the case?
NB:
If I save the integer number to a variable - the toFixed() method does work.
var c = 67;
c = c.toFixed(2);
console.log(c); // returns 67.00
See this jsBin
What is going on under the hood?