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

  • Home
  • SEARCH
  • 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 9236291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:15:24+00:00 2026-06-18T07:15:24+00:00

The typical way of creating a Javascript object is the following: var map =

  • 0

The typical way of creating a Javascript object is the following:

var map = new Object();
map[myKey1] = myObj1;
map[myKey2] = myObj2;

I need to create such a map where both keys and values are Strings. I have a large but static set of pairs to add to the map.

Is there any way to perform something like this in Javascript:

var map =  { { "aaa", "rrr" }, { "bbb", "ppp" } ... };

or do I have to perform something like this for each entry:

map["aaa"]="rrr";
map["bbb"]="ppp";
...

Basically, remaining Javascript code will loop over this map and extract values according to criterias known ‘at runtime’. If there is a better data structure for this looping job, I am interested too. My objective is to minimize code.

  • 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-18T07:15:26+00:00Added an answer on June 18, 2026 at 7:15 am

    JavaScript’s object literal syntax, which is typically used to instantiate objects (seriously, no one uses new Object or new Array), is as follows:

    var obj = {
        'key': 'value',
        'another key': 'another value',
         anUnquotedKey: 'more value!'
    };
    

    For arrays it’s:

    var arr = [
        'value',
        'another value',
        'even more values'
    ];
    

    If you need objects within objects, that’s fine too:

    var obj = {
        'subObject': {
            'key': 'value'
        },
        'another object': {
             'some key': 'some value',
             'another key': 'another value',
             'an array': [ 'this', 'is', 'ok', 'as', 'well' ]
        }
    }
    

    This convenient method of being able to instantiate static data is what led to the JSON data format.

    JSON is a little more picky, keys must be enclosed in double-quotes, as well as string values:

    {"foo":"bar", "keyWithIntegerValue":123}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In javascript, the typical way to new up an object is by doing it
Typical way of creating a CSV string (pseudocode): Create a CSV container object (like
Typical problem - I am trying to save new parent object with nested new
The typical syntax for creating a db link is as follows: create database link
I have a LinkedHashMap which I've been using in a typical way: adding new
I've followed the typical way a form has been setup in an application, which
What is the typical way to weigh results in MYSQL? I have a table
I'm learning socket programming (in python) and I was wondering what the best/typical way
A typical pattern is to create a child window in the message callback (
I'd like to provide some way of creating dynamically loadable plugins in my software.

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.