This article mainly describes the JavaScript midpoint "." The ambiguity. Need friends can come to the reference, I hope to help you
Point number "." There are two semantic semantics in JavaScript 1, the decimal point in arithmetic (floating-point number), such as 2.5 semantics 2, object properties, methods, such as [].push (2) There is hardly any hard to understand, but the following question is interesting. The code is as follows://How this line of code executes 1.toString (); The dot number in the Firebug is expressed in the above semantic 1, so the dot must be followed by a number, here with ToString, the report syntax is wrong. The workaround is simple, such as adding a parenthesis code as follows: (1). ToString (); It can be written in this way, but it's hard to understand some code as follows: 1..toString (); The reason why the browser can run, because the browser JS engine to "1..toString ()" understood as "1.0.toString ()". The first point here is semantic 1, and the second point is the semantics 2. There's even more strange writing, and there's no error. Copy code code as follows: 1. toString (); Note that the dot is preceded by a space. Obviously, the point number here is Semantic 2, that is, the JS engine ignores the space in front of the dot operator, regardless of the space before or after it is ignored. The following code is as follows: 1. ToString (); There is a space of 1 before and after the dot number. ToString (); There are two spaces around the point number 1. toString (); There is a tab 1 before the dot number. ToString (); The dot before and after each have a tab JS engine will not only ignore spaces, but also ignore the tab.