Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda