1.toString()
gives us Uncaught SyntaxError: Invalid or unexpected token
.
One the other hand, (1).toString()
returns '1'
.
Considering that typeof 1 === typeof (1)
(both are of type number
), why is this the case?
1.toString()
gives us Uncaught SyntaxError: Invalid or unexpected token
.
One the other hand, (1).toString()
returns '1'
.
Considering that typeof 1 === typeof (1)
(both are of type number
), why is this the case?
In JS number literals might be both integers and floats, so probably after finding .
after the number translator expects to parse a float, like 1.123
.