2

I know we could use object.constructor.name to get the class name in javascript object oriented programming. But is there a function to get instance name.

For example:

function className(){
    this.getName = function(){
    alert(this.InstanceName);
    };
}

objectA = new className();
objectA.getName();

How to print "objectA"?

Terence
  • 29
  • 6
  • Refer the Following Site for more Information Regarding this solution.. [http://stackoverflow.com/questions/6973866/javascript-get-type-instance-name](http://stackoverflow.com/questions/6973866/javascript-get-type-instance-name) [http://stackoverflow.com/questions/2460868/how-to-get-the-instance-name-of-an-object](http://stackoverflow.com/questions/2460868/how-to-get-the-instance-name-of-an-object) [http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript](http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript) [ – coolprarun Sep 05 '13 at 11:13
  • Also take a look at my answer here: http://stackoverflow.com/questions/12972262/javascript-get-name-of-instance-of-class/23294728#23294728 – Kmeixner Apr 25 '14 at 13:37

0 Answers0