2.toString()
The interpreter sees 2 and thinks "oh, number!". Then he sees the dot and thinks βoh, decimal number!β. And then he goes to the next character and sees t , and he gets confused. " 2.t not a valid decimal number," the message says, because it generates a syntax error.
2..toString()
The interpreter sees 2 and thinks "oh, number!". Then he sees the dot and thinks βoh, decimal number!β. Then he sees another point and thinks: βOh, I think this is the end of our number. Now we look at the properties of this object (number 2.0).β Then it calls the toString method of object 2.0 .
Casey chu
source share