Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
JavaScript Map RangeError: Invalid array length

I am using the docx node library and attempting to autogenerate a table from an array. The challenge is that beyond returning data I need to return a structure, but when I run my map it fails with the following:

RangeError: Invalid array length

Here is my sample code I am testing with.

const rowChildren = [
    {firstName : "Susan", lastName: "Steward"},
    {firstName : "Daniel", lastName: "Longbottom"},
    {firstName : "Jacob", lastName: "Black"}
  ];

const table = new Table({
    rows: [rowChildren.map(function(element){ return new TableRow({
      children: [
        new TableCell({
        children: [new Paragraph(element.firstName)],
    }), //each entry is an array of TableCell that make up this row
],
    })},
),
],
  });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your map() already return an array TableRow[], just remove you [ ] before map() at rows key. This will resolve your RangeError: Invalid array length error.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!