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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Use
Object.keys()or shim it in older browsers…If you wanted values, there is
Object.values()and if you want key and value, you can useObject.entries(), often paired withArray.prototype.forEach()like this…Alternatively, considering your use case, maybe this will do it…