For some reason, when I try to call toString
on a literal number, it fails:
> 5.toString()
SyntaxError: Unexpected token ILLEGAL
So I tried putting it in a variable, and it worked:
> var five = 5
undefined
> five.toString()
"5"
I thought that was a bit strange, and after some more experimenting, I found out that wrapping a literal in parenthesis somehow makes it work:
> (5).toString()
"5"
That seemed very strange! Why would wrapping the literal in parenthesis change anything? Why does 5.toString()
not work?