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

294
Visualizações
For ES6 classes is there a way to log which methods/arguments that were used and then call upon them again?

Currently I have a car class that has a lot of methods on it, most involved with generating parts of the car (door, wheels, cars,etc), and then returns the new car class with the new parts. I'd like to be able to call the class methods, and then log the methods and arguments used, and be able to do a "replay" of generating that car.

The only way I can think of is to insert some code in every method that records what just happened, push this log in an array, and then have a separate bloated method that is a bunch of switch statements that'll call upon the relevant method used. However that seems pretty inefficient and will have to be updated every time a new method is added and become too cumbersome. Is there an easier solution to tackle this?

Also am able to get the method names as strings with

Object.getOwnPropertyNames(Object.getPrototypeOf(dude)    

But this still doesn't solve logging the method used, and then using the method

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