If I run
var num = 23;
var n = num.toString();
var n = 15.toString();
Uncaught SyntaxError: Invalid or unexpected token
We see this as an Integer with a function being called on it.
The parser doesn't. The parser sees an attempt to declare a floating-point literal. The parser uses this:
It assumes that you are declaring a Floating-Point Literal because it is:
If you really, for all intents and purposes, want to call
23.toString(), the course of action is to isolate the literal like so:
(23).toString(); //interprets 23 as literal
23..toString(); //interprets 23. as literal
var foo = "The answer is " + 42;
So does this.
var bar = "39" - 0 + 3; //42
var baz = "39" + 3; //393!!!