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

166
Views
How to create a nested functions in JavaScript

I'm building own API to generate dynamic table in JS (I know about dataTables). I need some another functions but the scheme of work is similar.

I'm wondering how works a function e.g. data() in dataTables while toArray() is inside this function?

for example: when I want to get data I need to call dataTable().data() but if I want to get data as JS array I call dataTable().data().toArray();

I try in this case at shown below:

return {
   data: {
      toArray: () => {
         return myArray;
      }
   }
}

My above code is works but how can I call a data() function that it return to me another data without call toArray() function?

I want to get this effect:

  1. MydataTable.data() - I get array of HTML object
  2. MydataTable.data().toArray() - I get JS array from HTML objects

prototype

function oData() {
    this.arr = Obj.HTML;
}
    
oData.prototype.data = () => {
    return Obj.HTML;
}
    
oData.prototype.toArray = () => {
    return Obj.data;
}

let obj = new oData();

obj.data() return array of HTML objects

obj.toArray() return array of data objects

but I want use obj.data().toArray() to get array of data objects

about 4 years ago · Juan Pablo Isaza
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!