How can I get the names of the methods in a constructor of a class?

I would caution against blindly removing the first element of the array. It is, in all likelihood, the constructor, but do you really want to take that chance?

I’ve gone with this solution, which explicitly removes the constructor from the array.

const methods = Object.getOwnPropertyNames(
  this.constructor.prototype
).filter((m) => m !== 'constructor');
1 Like