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 6796967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:33:05+00:00 2026-05-26T18:33:05+00:00

In Javascript there are various reserved words that cannot be used inside Identifiers ;

  • 0

In Javascript there are various reserved words that cannot be used inside Identifiers; some of those are actually reserved for future use. To clarify a bit, an Identifier is an Identifier Name but not a reserved word. The exact grammar of identifier names is not relevant here.

According to the last paragraph here, though, it seems that there are some place where it is valid to use any Identifier Name, even if it is a reserved word. The article mentions as valid

a.import
a["import"]
a = { import: "test" }

While it is clear to me that the second form is legal, I always thought that the first and the third were not.

In fact, this resource denotes

foo.if

as invalid code.

Are there some places were reserved words are actually valid?

As a motivation, I am writing an API where it would make sense to pass objects of the form

{
    in: foo,
    out: bar
}

but I don’t want to force users to put brackets around in.

  • 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-05-26T18:33:05+00:00Added an answer on May 26, 2026 at 6:33 pm

    This is a change in ECMA-262 between editions 3 and 5 (which you can get here).

    In both editions, section 7.6 defines an Identifier as

    Identifier ::
        IdentifierName but not ReservedWord
    

    However, in section 11.2.1, property accessors using dot notation were changed from

    MemberExpression . Identifier
    CallExpression . Identifier
    

    in edition 3 to

    MemberExpression . IdentifierName
    CallExpression . IdentifierName
    

    in edition 5, ie using reserved names as dot accessors is indeed legal now.

    I don’t know if this change was made just because the restriction to Identifier is syntactically unnecessary because none of the reserved words could ever legally follow a ., or if it also codified existing practice of various implementations.

    PS: After some digging, I found the following in a mail from Allen Wirfs-Brock, project editor for edition 5:

    The ES3 grammar does not allow reserved words (such as true and false) to be used as a PropertyName or to the right of the period in a MemberExpression. Your tests verify that most implementations conform to that restriction while FF has a "non-standard" extension that allows reserved words (or at least the ones you tested) to be used in those contexts.

    ES3.1 intentionally adopted the FF extension as a standard part of the language, so when the other implementation are eventually updated to support ES3.1 they should no long report errors for your test cases.

    Note that ECMAScript 3.1 was the original name for what is now known as ECMAScript 5.

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

Sidebar

Related Questions

Web-Applications these days make extensive use of Javascript, for example various Google Products like
In Javascript is there a function that returns the number of times that a
Is there a javascript function I can use to detect whether a specific silverlight
There are various ways to handle session timeouts, like meta refreshes javascript on load
I've been looking at the various JavaScript UI libraries and am wondering if there's
Is there a site anywhere that documents all standard JavaScript DOM methods, events and
First there was the ASP.NET validators and we used them... Then some people on
Are there javascript libraries that provide forward compatibility with particular implementations? For example, such
Is there a way we can persist javascript variables across various pages? Suppose in
Am using below tools to debug JavaScript in various browsers. Is there a common

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.