Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda