[X]

1.toString() Is An Error

luljs still works

Calling a method on a number literal needs two dots, or a space before the one.

In 2026: Still true. The parser reads the dot after a digit as the start of a decimal, so 1.toString() tries to parse 1.toString as a number and throws. The fixes are 1..toString(2), where the first dot is the decimal point and the second is the call, or (1).toString(2), or 1 .toString(2) with a space.

Where it came from: A consequence of the numeric literal grammar, documented on MDN's Number.prototype.toString page. MDN

<script>
document.write('<p><code>(1).toString(2)</code> is <b>' + (1).toString(2) + '</b></p>');
document.write('<p><code>255..toString(16)</code> is <b>' + 255..toString(16) + '</b></p>');
document.write('<p><code>1.toString(2)</code> is a <b>SyntaxError</b>: the parser reads <code>1.</code> as a decimal point.</p>');
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›