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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:16:25+00:00 2026-05-22T15:16:25+00:00

jshashtable states: JavaScript’s built-in objects do provide hashtable functionality using the square brackets notation

  • 0

jshashtable states:

JavaScript’s built-in objects do provide hashtable functionality using
the square brackets notation for
properties, provided your keys are
strings or numbers:

From what I know, keys are only strings, (since numbers are coerced into strings anyway). I just want to check and be sure that what is stated above is false (since keys can’t be numbers).

Did the ECMA standard state anything about this?

Or is the implementation browser-specific?

  • 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-22T15:16:26+00:00Added an answer on May 22, 2026 at 3:16 pm

    JavaScript’s built-in objects do provide hashtable functionality using
    the square brackets notation for properties, provided your keys are
    strings or numbers

    That seems to be incorrect – object keys may be strings or (since ECMAScript 2015, aka ECMA-262 ed 6) symbols. But that is a different topic to square bracket property access.

    See ECMA-262 ed 3 § 11.2.1 (Please also see ECMAScript 2017 (draft).):

    Properties are accessed by name, using either the dot notation:

    MemberExpression . IdentifierName

    CallExpression . IdentifierName

    or the bracket notation:

    MemberExpression [ Expression ]

    CallExpression [ Expression ]

    The dot notation is explained by the following syntactic conversion:

    MemberExpression . IdentifierName

    is identical in its behaviour to

    MemberExpression [ <identifier-name-string> ]

    and similarly

    CallExpression . IdentifierName

    is identical in its behaviour to

    CallExpression [ <identifier-name-string> ]

    where <identifier-name-string> is a string literal containing the
    same sequence of characters after processing of Unicode escape
    sequences as the IdentifierName.

    So when using dot notation, the bit after the dot must fit the criteria for an IdentifierName. But when using square brackets, an expression is provided that is evaluated and resolved to a string.

    Briefly, square bracket notation is provided so that properties can be accessed using an expression, e.g.

    var y = {};
    var x = 'foo';
    y[x] = 'foo value';
    

    In the above, x is provided in square brackets so it is evaluated, returning the string ‘foo’. Since this property doesn’t exist on y yet, it is added. The foo property of y is then assigned a value of ‘foo value’.

    In general terms, the expression in the square brackets is evaluated and its toString() method called. It is that value that is used as the property name.

    In the dot property access method, the identifier is not evaluated, so:

    y.bar = 'bar value';
    

    creates a property bar with a value bar value.

    If you want to create a numeric property, then:

    y[5] = 5;
    

    will evaluate 5, see it’s not a string, call (more or less) Number(5).toString() which returns the string 5, which is used for the property name. It is then assigned the value 5, which is a number.

    This answer was written when ECMAScript ed3 was current, however things have moved on. Please see later references and MDN.

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

Sidebar

Related Questions

I have the following for my HashTable structure: typedef char *HashKey; typedef int HashValue;
A few days ago I posted this question and everyone suggested me to use
How can I find or list PowerShell's -as family of parameters? So far I
I'm trying to build my own Hash Table in C from scratch as an
I have various JS libraries in my web application, which are loaded before my
In my small Core Data application I have some NSTableView views binded with NSArrayController

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.