0

In Python I can override __str__ method of a class, so str(class_instance) would return what method __str__ of such class returns.

Is there any analog way in javascript to define what String(classInstance) returns?

HuLu ViCa
  • 5,077
  • 10
  • 43
  • 93
  • 5
    `toString` is the function you are looking for – ASDFGerte Apr 16 '21 at 23:33
  • yes, there is a way, but what do you have in mind, specifically? – Mister Jojo Apr 16 '21 at 23:38
  • Does this answer your question? [Is it possible to override JavaScript's toString() function to provide meaningful output for debugging?](https://stackoverflow.com/questions/6307514/is-it-possible-to-override-javascripts-tostring-function-to-provide-meaningfu) – SuperStormer Apr 16 '21 at 23:48

0 Answers0