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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:08:30+00:00 2026-06-08T17:08:30+00:00

In Python I can use the .values() method to iterate over the values of

  • 0

In Python I can use the .values() method to iterate over the values of a dictionary.

For example:

mydict = {'a': [3,5,6,43,3,6,3,],
          'b': [87,65,3,45,7,8],
          'c': [34,57,8,9,9,2],}
values = mydict.values():

Where values contains:

[
    [3,5,6,43,3,6,3,],
    [87,65,3,45,7,8],
    [34,57,8,9,9,2],
]

How can I get only the values of the dictionary in Javascript?

My original print example wasn’t clear on what I’d like to do. I only want a list/array of the values within the dictionary.

I realize I can cycle through the list and create a new list of the values, but is there a better way?

  • 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-08T17:08:31+00:00Added an answer on June 8, 2026 at 5:08 pm

    Updated
    I’ve upvoted Adnan’s answer as it was the first. I’m just posting a bit more details if it helps.

    The for..in loop is what you are looking for –

    var dictionary = {
        id:'value',
        idNext: 'value 2'
    }
    
    for (var key in dictionary){
        //key will be -> 'id'
        //dictionary[key] -> 'value'
    }
    

    To get all the keys in the dictionary object, you can Object.keys(dictionary)
    This means, you can do the same thing in an array loop —

    var keys = Object.keys(dictionary);
    keys.forEach(function(key){
        console.log(key, dictionary[key]);
    });
    

    This proves especially handy when you want to filter keys without writing ugly if..else loops.

    keys.filter(function(key){
        //return dictionary[key] % 2 === 0;
        //return !key.match(/regex/)
        // and so on
    });
    

    Update –
    To get all the values in the dictionary, currently there is no other way than to perform a loop. How you do the loop is a matter of choice though. Personally, I prefer

    var dictionary = {
        a: [1,2,3, 4],
        b:[5,6,7]
    }
    var values = Object.keys(dictionary).map(function(key){
        return dictionary[key];
    });
    //will return [[1,2,3,4], [5,6,7]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Python I can use get method to get value from an dictionary without
In Python I can use the iterkeys() method to iterate over the keys of
When I use the AllegroGraph 4.6 Python API, I can use the connection.addTriple() method
I can successfully use Python to create a database and run the execute() method
In python we can use multiprocessing modules. If there is a similar library in
I've noticed that you can use python libdiff to output a side by side
I was wondering how can we can use the python module networkX to implement
In python, is there a way I can use instance variables as optional arguments
In recent versions of python, one can use something like with open('abc.txt') as f:
I'm planning to use very big numbers in Python, but wonder if Python can

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.