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

166
Visualizações
values not being passed between functions

I've been using javascript for years and am expanding my knowledge but dont understand the behaviour in the following code (simplified for brevity):

page.html

$(document).ready(function() {
        Modal.show('full', 'Hello World!');
});

Modal.js

class Modal {
     show({ type, title = '' }) {
        var builtModal = this.build(type, title)
        // do something
    }

    build({ type, title }) {
       // do something
    }
}

In Modal.show, type == 'full' & title is correct but in Modal.build (called from Modal.show) type == undefined & title == "". I'm expecting the values to be set as per the calling function... Any ideas??

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

In the function call you use two separate arguments. Try changing it to:

Modal.show({ type: 'full', title: 'Hello World!'});
about 4 years ago · Juan Pablo Isaza Relatório

0

Since you're using destructuring in the parameter lists, you need to pass objects to be destructured:

$(document).ready(function() {
    Modal.show({type: 'full', title: 'Hello World!');
});

class Modal {
    show({ type, title = '' }) {
        var builtModal = this.build({type, title})
        // do something
    }

    build({ type, title }) {
       // do something
    }
}
about 4 years ago · Juan Pablo Isaza Relatório
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