How to get an object class name at runtime in TypeScript

1 Answer

0 votes
class Example {}

const instance = new Example();

console.log(instance.constructor.name); 
console.log(Example.name);             


   
    
    
    
/*
run:
    
"Example" 
"Example" 
    
*/

 



answered Feb 27, 2022 by avibootz

Related questions

1 answer 160 views
1 answer 157 views
1 answer 116 views
1 answer 130 views
1 answer 112 views
...