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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:48:24+00:00 2026-06-06T08:48:24+00:00

In coffeescript we can do this way: rows = [ {a: 1} {b: 2}

  • 0

In coffeescript we can do this way:

rows = [
    {a: 1}
    {b: 2}
]

for row in rows
    for k,v of row
        alert "#{k}: #{v}"

So why we can’t do that this way?:

for k,v of row for row in rows
    alert "#{k}: #{v}"
  • 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-06T08:48:25+00:00Added an answer on June 6, 2026 at 8:48 am

    You cannot do it that way, but you can invert the inner loop and put the loop construct after the expression:

    for row in rows
      alert "#{k}: #{v}" for k,v of row
    

    And, as that inner loop is also an expression, you can also invert the outer loop the same way 😀

    alert "#{k}: #{v}" for k,v of row for row in rows
    

    The most similar to what you were trying to write is probably this:

    for row in rows then for k,v of row 
      alert "#{k}: #{v}"
    

    Which can be further inlined using another then (the then keyword is usually equivalent to a newline and adding one level of indentation):

    for row in rows then for k,v of row then alert "#{k}: #{v}"
    

    All of these alternatives generate the same JS code, so picking one or another will not result on degraded performance or anything like that 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I rewrite this code to coffeescript: $('.delete_action').click(function(event) { $.get('/delete_action?name=' + event.target.name +
This is my first Coffeescript function and can't figure out how to get this
I'm just asking this out of curiosity : Is there any tool that can
I have a working coffeescript/backbone idiom that looks like this: SidebarWidgets = ((() ->
In clojure, I can destructure a map like this: (let [{:keys [key1 key2]} {:key1
I'm trying to build a way to do PHPUnit-style test case classes in CoffeeScript.
I've got this code that checks for the empty or null string. It's working
Is there a way to have some code run in the browser after coffeescript
TLDR: What can you do to combine multiple CoffeeScript files into one JS file,
I'm new to CoffeeScript, and I like the CoffeeScript classes, but can't work out

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.