This question was seen on the--stackoverflow of the famous question and answer website.
I have seen this problem of JavaScript before, but I didn't know it well, today I saw the answer on the StackOverflow, I feel good, and write it down to share with you.
The description of the
problem is this :
Copy Code code as follows:
Console.log (10..toString ());//10
Console.log (10.toString ());//syntaxerror:unexpected token illegal
Why the former is normal, and the latter error.
The reason is, in JavaScript, the "." Behind the number. The meaning of the operator is not certain. Because it may be either a flag for floating-point numbers or an operator of an object's properties. But the JavaScript interpreter treats him as a floating-point symbol, so the above code is equivalent to the following
Copy Code code as follows:
Console.log (10.). ToString ());/Normal
Console.log (10.) ToString ());//In this case, of course, there is an error (end) ^_^