4

Why

123.toString()

throws an SyntaxError

while

123..toString()

is not?

aztack
  • 4,376
  • 5
  • 32
  • 50

1 Answers1

10

The first . you type in a Number literal is the decimal point.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 2
    `123..toString()` is equivalent to `(123).toString()` :) –  Apr 15 '13 at 09:22
  • why doesn't 10.0..toString() work? should result in a string "10.0" – Ricky-U May 03 '22 at 07:01
  • @Ricky-U Dot-notation syntax is “value dot property-name” not “value dot dot property-name” – Quentin May 03 '22 at 07:04
  • yes i'm aware of dot notation syntax, but if the first . is a number literal representation a decimal point, then why 10.0..toString() does not work? and 10..toString() works. – Ricky-U May 04 '22 at 07:45
  • @Ricky-U — Yes, the **first** dot is the decimal point is but `10.0..toString()` has **three** dots in it. The second expects a property name after it, not another dot. – Quentin May 04 '22 at 07:46