Is there any solution to get the function name of an object?

function alertClassOrObject (o) {
   window.alert(o.objectName); //"myObj" OR "myClass" as a String
}

function myClass () {
   this.foo = function () {
       alertClassOrObject(this);
   }
}

var myObj = new myClass();
myObj.foo();

for (var k in this) {...} – there is no information about the className or ObjectName. Is it possible to get one of them?

8 Answers
8

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *