Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Using an array to access a JS object value

I have an object that associates a key to an array of values. Eg.

var map = {
    "600": [
        "600",
        "0"
    ],
    "602": [
        "600",
        "0"
    ],
    "6723": [
        "6646",
        "600",
        "0"
    ],
    "6646": [
        "600",
        "0"
    ]
}

I noticed that Javascript will resolve a key when using an array for key lookup.

Eg.

map[600] => ["600","0"]
map[[600]] => ["600","0"]
map[[[600]]] => ["600","0"]

Curious about this inherent input flattening? Also when you pass multi-value array, JS will pick that last argument. But if nest arrays it returns undefined.

Eg.

map[600, 6723] => ["6646","600","0"]
map[[600, 6723]] => undefined

Any insights/links/docs for what is happening here? Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!