Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:15:38+00:00 2026-06-03T05:15:38+00:00

Since I started working with JS, I’ve thought the only way to invoke a

  • 0

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:

1.toString();
// SyntaxError: identifier starts immediately after numeric literal

(1).toString();
// "1"

Today, it occurred to me to try this:

0.1.toString();
// "0.1"

Why does this work? A pointer into the official spec would be great.

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

Property names can begin with digits

var obj = { "1" : 1, "2" : 2 };

Property names that begin with digits can only be referenced with square brackets

obj.1;
// SyntaxError: Unexpected token ILLEGAL
obj['1'];
// 1

Also:

1['toString']();
// '1'

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:15:39+00:00Added an answer on June 3, 2026 at 5:15 am

    Once it’s seen the first . in 0.1, then a subsequent . cannot be part of the number.

    It’s all about ambiguity.

    edit — section 7.8.3 of the spec explicitly insists on this:

    The source character immediately following a NumericLiteral must not be an IdentifierStart or DecimalDigit.

    I’m not sure exactly what that’s trying to prevent, but the JavaScript lexer is pretty gnarly, mostly thanks to the regex literal grammar and the need for a weird parser-lexer hack to deal with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started in iOS development after working in Android since the
Since I started learning F# and OCaml last year, I've read a huge number
I have just started working with Android ListView . However, setAdapter function in my
Something I have found strange since I started working on GWT is how few
Since I have just started working with Facebook's api I had a few questions
I been working on porting my application on Rails 3.0.7 ,ever since I started
I am a .NET mobile developer and since i started working with android, i
I haven't understood this since I had started working with Swing. Why BoxLayout with
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
Since I started to develop in a test/behavior driven style, I appreciated the ability

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.