let x=5; // x has type number
alert(x.toString()); // why does this work, since x is a number variable, not an object?
x.toString()
should not work, since x is not an object.
Similarly, 10.toString()
does not work,
but (10).toString()
does work.
I was expecting that the toString() method would not work on any of these cases, since neither x, 10, nor (10) are objects.
I also noticed that x[“toString()”] returns undefined, creating another puzzle.