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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:59:49+00:00 2026-06-04T03:59:49+00:00

I have a dictionary: var driversCounter = { "one": 1, "two": 2, "three": 3,

  • 0

I have a dictionary:

var driversCounter = {
    "one":   1,
    "two":   2,
    "three": 3,
    "four":  4,
    "five":  5
}

Now, I need to show it in a dropdownlist. How can I get the collection of keys in my dictionary?

  • 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-04T03:59:50+00:00Added an answer on June 4, 2026 at 3:59 am

    Use Object.keys() or shim it in older browsers…

    const keys = Object.keys(driversCounter);
    

    If you wanted values, there is Object.values() and if you want key and value, you can use Object.entries(), often paired with Array.prototype.forEach() like this…

    Object.entries(driversCounter).forEach(([key, value]) => {
       console.log(key, value);
    });
    

    Alternatively, considering your use case, maybe this will do it…

    var selectBox, option, prop;
    
    selectBox = document.getElementById("drivers");
    
    for (prop in driversCounter) {
       option = document.createElement("option");
       option.textContent = prop;
       option.value = driversCounter[prop];
       selectBox.add(option);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have the following javascript dictionary var a = {}; a['SVG343'] =
I have a dictionary dict1['a'] = [ [1,2], [3,4] ] and need to generate
I have a dictionary (keys are integers, values are float). I would now ask
Let's say I have a Dictionary<string,object> like so: var foo = new Dictionary<string, object>();
I have a Javascipt object which I use as dictionary var obj={ xxx:'1' yyy:'2'
Let's say I have a Javascript associative array (a.k.a. hash, a.k.a. dictionary): var a
Hi guys I have a dictionary which has to be shared between two different
I have: Dictionary<int, List<int>> dict = new ... var a = SomeEntity.Where(f => dict[f.key].Contains(f.someValue))
I have a dictionary with a key value pair and need to loop through
I have two Dictionary<string, Item> s. Item has a has a public property int

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.