You can refer to the object name in instance.constructor.name. Function.name - JavaScript | MDN
instance.constructor.name
function Foo() {}; let foo = new Foo(); console.log(foo.constructor.name); //=> 'Foo'
Recommended Posts