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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:28:57+00:00 2026-06-12T19:28:57+00:00

Possible Duplicate: How to access a numeric property? I am trying to read an

  • 0

Possible Duplicate:
How to access a numeric property?

I am trying to read an object where the keys are numbers. But unfortunately, when I try reading this object:

Salary:{
  "2012_08":"5555",
  "2012_09":"6666",
  "2012_10":"7777"
}
var augsalary =  salary.2012_08;

it throws an error. My question is this: “2012_08” is the year month combination and that cannot change to be stored as a string. How can I still access the value with that key?

  • 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-12T19:28:58+00:00Added an answer on June 12, 2026 at 7:28 pm

    First, your Javascript code is invalid, perhaps you meant

    var Salary = {
      "2012_08":"5555",
      "2012_09":"6666",
      "2012_10":"7777"
    }
    var augsalary =  salary.2012_08;
    

    Second, an all too common confusion is to talk of JSON objects. Salary is NOT a JSON object, it is a JavaScript object. JSON is a notation for
    expressing a large subset of all JavaScript objects as strings. These strings can then
    be transmitted to other parts of your code or other computers where they can be converted back into objects for processing. So in you question Salary would be data converted from a received JSON string.

    JS has arrays and objects.

    Objects are the most basic, they can have properties whose names can be any arbitrary string. Two forms of object property access is provided : brace and dot notation. Brace notation is universal, you specify the property name value as a string or variable value inside braces after the object name. Dot notation is a shorthand and can be used only when the name of the property has the form of a valid JS variable name.

    Arrays are basic objects which have the additional feature of maintaining an ordered list of their numeric property names. You can add non numeric property names to arrays but they do not participate in any Array function.

    So in you example you do not have numeric keys or property names since they contain a ‘_’ character. Since they start with a digit you cannot use dot notation and must use the brace notation to access them as explained by dystroy below.

    Hoping my little lesson helps you better understand the basics.

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

Sidebar

Related Questions

Possible Duplicate: javascript object, access variable property name? I'm trying to call a method
Possible Duplicate: How do I access this object property? The data returned in a
Possible Duplicate: obj-c access property dynamically I'm attempting to access an object’s properties dynamically
Possible Duplicate: Casting an Array with Numeric Keys as an Object I was wondering
Possible Duplicate: The calling thread cannot access this object because a different thread owns
Possible Duplicate: Casing an Array with Numeric Keys as an Object I made a
Possible Duplicate: Access the first property of an object I have a hash h
Possible Duplicate: How to access this attribute using jquery, given a div defined by
Possible Duplicate: How Do I Access This Variable? Lets say I have the code:
Possible Duplicate: C++ delete - It deletes my objects but I can still access

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.