Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!