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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:59:44+00:00 2026-05-20T19:59:44+00:00

In Python I could do something like myMap = {key: [value1, value2]} and then

  • 0

In Python I could do something like myMap = {key: [value1, value2]} and then access the value2 using myMap[key][1]

Can I do something like this in JavaScript?

  • 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-20T19:59:45+00:00Added an answer on May 20, 2026 at 7:59 pm

    Well, you can do this:

    var myMap = { key: [ value1, value2 ] };
    var array = myMap.key; // or myMap["key"]
    

    JavaScript doesn’t have an “associative array” type, one that combines “map” behavior with array behavior like keeping track of the number of properties. Thus the common thing to do is use a plain object. In modern JavaScript now (2017), there’s an explicit Map facility that allows keys to be of any type, not just strings as when using simple objects.

    JavaScript is a little bit silly about the object literal notation, in that it won’t let you use reserved words for keys unless you quote them:

    var myMap = { 'function': 'hello world' };
    

    The quote syntax allows any string to be used as a property name. To access such properties, you’d use the [ ] operator

    console.log(myMap["function"]); // "hello world"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In python you can do something like this to import a module using a
Is it possible to do something like this in Python using regular expressions? Increment
In Python, I often have tests which look something like this: tests = [
I can call my script like this: python D:\myscript.py 60 And in the script
everyone, my python code is something like this: try: foo1() except FooError1: try: foo2()
Python has this wonderful way of handling string substitutions using dictionaries: >>> 'The %(site)s
I have a dict of configuration variables that looks something like this: self.config =
In many languages we can do something like: for (int i = 0; i
I have a model, Rating , which looks something like this: class Rating(models.Model): upvotes
My setup.py looks something like this: from distutils.core import setup setup( [...] install_requires=['gevent', 'ssl',

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.