What\'s the difference between the following code?
var a = 1;
a.toString(); // outputs: \"1\"
But this throws an error:
1.t
Try to Change the Syntax,
(1).toString()
Numbers can have decimals, so the syntax for ending in a decimal is a bit ambiguous when you go to parse the code, use parenthesis to be valid. It's a bit clearer when you see that this is also valid:
(1.).toString()
However with just
1.toString() it's trying to parse as a number with a decimal, and it fails.