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

121
Visualizações
Method that will read different settings in the object and depending on the incoming data execute different methods

I study vanila JS, and try to optimize my code. I want to create a universal method that will read different settings and, depending on the incoming data launch another methods. I don’t really want to use with a lot of IF IF ELSE

What I got

Settings = {
SlideToShow: 2,
SlidetoScrolle: 2,
Scrollable: false
}

My "universal" method

_settingsReader(settings) {
        for (const key in settings) {
            if (Object.hasOwnProperty.call(settings, key)) {
                this._set + key + (settings[key])  
}

All problems hide here "this._set + key + (settings[key])". It doesn't call a method.

I just don't understand if something like this is possible. And how to implement it.

Metods that I want to launch

_setSlideToShow(param);
_setSlidetoScrolle(param);
_setScrollable(param);

I hope I was able to explain what I would like to see in the final result. I will be very happy if someone can help me with this problem.

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