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

  • Home
  • SEARCH
  • 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 8820191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:32:51+00:00 2026-06-14T05:32:51+00:00

I discovered dōmo from Jed Schmidt which seems useful for creating server side HTML

  • 0

I discovered dōmo from Jed Schmidt which seems useful for creating server side HTML in node.js.

Basic stuff works but I lack to see how I can use loops like forEach() on arrays to create things like table rows. I created a basic example:

var domo = require('domo');

var fruits = [];
fruits.push("banana", "apple", "peach");

var document = DOCUMENT({type: "html"},
  HTML(
    HEAD(
      TITLE("bla"),
      SCRIPT({src: "/script.js"})
      ),
    BODY(
      TABLE(
        THEAD( TR( TD("Predicate"), TD("Object"))),
        TBODY(
          fruits.forEach(function(value, index) {
            console.log("I am in forEach");
            console.log("Value: "+value);
            console.log("Key: "+index);
            TR(
              TD(index),
              TD(value)
              )
          })
          )
        )

      )
    )).outerHTML;

console.log(document);

This currently results in this output:

<!DOCTYPE html>
<html>
    <head>
        <title>
            bla
        </title>
        <script src="/script.js" type="text/javascript">
</script>
    </head>
    <body>
        <table>
            <thead>
                <tr>
                    <td>
                        Predicate
                    </td>
                    <td>
                        Object
                    </td>
                </tr>
            </thead>
            <tbody>
                <!--undefined-->
            </tbody>
        </table>
    </body>
</html>

If I get that correctly I cannot access the scope of domo within the forEach loop. Is this the right interpretation and what would be the correct working way to do that?

Solution:

Thanks to the hint from Bergi and a fix by Jed Schmidt this fragment now works (domo >=0.5.5):

TBODY( fruits.map(function(value, index) {
  return TR(
    TD(String(index)),
    TD(value)
    );
}))
)
  • 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-14T05:32:53+00:00Added an answer on June 14, 2026 at 5:32 am

    forEach returns undefined after having iterated the array.

    I don’t know whether those functions accept arrays as arguments, but you might try map:

    TBODY( fruits.map(function(value, index) {
        console.log("I am in map");
        console.log("Value: "+value);
        console.log("Key: "+index);
        return TR(
    //  ^^^^^^ dont forget this
            TD(index),
            TD(value)
        );
    }))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen a plugin for Vim called AutoClose (discovered from this post) which automatically
I have just discovered a package for R to retrieve abstract from pubmed, which
I have discovered that results coming from my SQL Server are having the field
I discovered Microsoft's .Net charting controls from another post here, and so far I
I discovered that it is possible to extract the hard-coded strings from a binary.
I discovered https://developers.google.com/speed/pagespeed/ the other day and have improved my website's page speed from
I recently discovered the use of pure functions and subroutines in Fortran. From what
I just discovered Ra from Ubuntu repositories. Has anyone used it in actual projects?
I discovered earlier tonight that files and folders I have removed from my C#
We are currently migrating from PHP4 to PHP5 and have discovered an issue. In

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.