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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:21:58+00:00 2026-06-10T13:21:58+00:00

Possible Duplicate: JavaScript property access: dot notation vs. brackets? I’m a total newbie to

  • 0

Possible Duplicate:
JavaScript property access: dot notation vs. brackets?

I’m a total newbie to chrome extensions.
I know Java but Javascript is something entirely different.

I would like to ask what is the difference between localStorage["something"] and localStorage.something?

The square bracket vs dot.

  • 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-10T13:21:59+00:00Added an answer on June 10, 2026 at 1:21 pm

    There is no difference. In fact, there is no difference between the two syntaxes in JavaScript as a whole:

    someObj.someProp === somObj["someProp"];
    

    The only difference is that certain characters are valid in a string and not in a dot-property name:

    someObj["some-prop"] // valid
    someObj.some-prop // this is actually the value of `someObj.some` minus the value of `prop`
    

    Note that both of these methods of storing values in localStorage are also the same as using the .getItem and .setItem methods. According to the W3C spec:

    Each Storage object provides access to a list of key/value pairs, which are sometimes called items.

    These items are accessible and mutable via the object property of the same name or by refering to them by name using .getItem and .setItem. The only difference is that the functions can be overwritten to provide wrappering, e.g., to JSON-ify the object before storage:

    localStorage.setItem = function(key, val) {
        localStorage[key] = JSON.stringify(val);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: JavaScript property access: dot notation vs. brackets? Let's consider I have an
Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
Possible Duplicate: javascript object, access variable property name? I'm sure it can be done
Possible Duplicate: Pick random property from a Javascript object suppose I have a javascript
Possible Duplicate: Detecting an undefined object property in JavaScript From the below JavaScript sample,
Possible Duplicate: Detecting an undefined object property in JavaScript javascript undefined compare How we
Possible Duplicate: JavaScript: Know when an image is fully loaded I have this code:
Possible Duplicate: Javascript Array.sort implementation? I want to know how .sort() works in JavaScript.
Possible Duplicate: Sorting JavaScript Object by property value Since I've noticed the browser can't
Possible Duplicate: How does JavaScript .prototype work? What is the use of prototype property

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.