This is a question on the famous Q & A website --Stackoverflow.
I have also seen this question about JavaScript before, but I have no in-depth understanding. Today I have seen the answer on stackoverflow. It feels good. I will write it down and share it with you.
The problem is described as follows:
1Console. Log (10.. Tostring ());//102 3Console. Log (10. Tostring ());//Syntaxerror: Unexpected token illegal
Why is the former normal while the latter reporting an error.
The reason is that in Javascript, the "." Operator after the number is meaningless. It can be both a floating point sign and an operator that obtains the attributes of an object. However, the javascript interpreter regards it as a floating point number, so the aboveCodeIt is equivalent to the following:
1Console. Log (10.). tostring ());//Normal2 3Console. Log (10.) tostring ());//In this case, of course, an error is reported.
(End) ^_^