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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:17:19+00:00 2026-06-07T08:17:19+00:00

Right now, I am doing this in CoffeeScript: keys = (key for key of

  • 0

Right now, I am doing this in CoffeeScript:

keys = (key for key of data)
values = (v for k,v of data)

Where data is an an object (not an array). I am trying to create two arrays, where keys is an array of the property names and values is an array of the values.

This compiles to:

var keys, values;
keys = (function() {
    var _results;
    _results = [];
    for (key in data) {
      _results.push(key);
    }
    return _results;
  })();
  values = (function() {
    var _results;
    _results = [];
    for (k in data) {
      v = data[k];
      _results.push(v);
    }
    return _results;
  })();

I’d like to be able to combine these two loops into a single loop, and can’t figure out how (or if it’s possible) to do this using a list comprehension.

A different attempt I made was to create two arrays and push the items to them myself:

keys = []
values = []
keys.push k for k,v of data

This lets me push the key just fine, but I can’t figure out the syntax to push to values as well.

How can I create two arrays from a single list comprehension? Am I better off writing the loop myself?

  • 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-07T08:17:21+00:00Added an answer on June 7, 2026 at 8:17 am

    I think the simplest would be to loop yourself:

    keys = []
    values = []
    for key, value of data
       keys.push key
       values.push value
    

    which transpiles as

    var key, keys, value, values;
    
    keys = [];
    
    values = [];
    
    for (key in data) {
      value = data[key];
      keys.push(key);
      values.push(value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm doing this but it seems to not work right. Thanks for
Right now I'm doing this: SELECT * FROM messages WHERE location_id = 7 AND
What is the most efficient way to do this? Right now I am doing
Right now I'm doing this: class MyTest(Base): __tablename__ = 'mytest' id = Column(Integer, primary_key
I need to read last 8 bytes from byte array. Right now im doing
Please look at the image below. Right now I am doing this with a
Right now I'm doing it this way: Within my applet, I connect to the
So right now I'm doing this: $(.radio_visible).hide().removeClass(radio_visible); But what I'd like to be able
Right now I'm doing as follow: uint8_t ManualFlow = 40; // 0 -> 255
I have a problem here. Right now I'm doing my Web Based Application, my

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.