What are the rules for invoking functions on number literals in JS?
<p>Since I started working with JS, I've thought the only way to invoke a function on a number literal is to put it in expression position by wrapping it with parens, like so:</p>

<pre class="lang-js prettyprint-override"><code>1.toString();
// SyntaxError: identifier starts immediately after numeric literal

(1).toString();
// "1"
</code></pre>

<p>Today, it occurred to me to try this:</p>

<pre class="lang-js prettyprint-override"><code>0.1.toString();
// "0.1"
</code></pre>

<p>Why does this work?  A pointer into the official spec would be great.</p>

<p><strong>Edit</strong> Ambiguity was my first thought, but then decided that there's no ambiguity in <code>1.toString()</code> either.  It's deeper than I first thought, but I still think I'm right.  Here's why:</p>

<p><strong>Property names <em>can</em> begin with digits</strong></p>

<pre class="lang-js prettyprint-override"><code>var obj = { "1" : 1, "2" : 2 };
</code></pre>

<p><strong>Property names that begin with digits can only be referenced with square brackets</strong></p>

<pre class="lang-js prettyprint-override"><code>obj.1;
// SyntaxError: Unexpected token ILLEGAL
obj['1'];
// 1
</code></pre>

<p>Also:</p>

<pre class="lang-js prettyprint-override"><code>1['toString']();
// '1'
</code></pre>

<p>Therefore, <code>1.</code> followed by any non-digit will always be a method call or property access, never a decimal number.  Likewise, <code>1.</code> followed by any digit will always be a decimal number, never a method call or property access.</p>
