Is it possible to dynamically determine the variable name of an object instance, e.g,
I create an instance of my object:
NewObject = new MyObject();
Within the constructor i want to be able to determine that the instance is called "NewObject":
function MyObject()
{
this.name = code_to_determine_my_name;
}
This should evaluate to MyObject.name == "NewObject"
I could of course pass the name as a parameter to the constructor but am trying to avoid this.
Anyone know how to accomplish this?
tnks in advance. lachlan@cynaptic.net
I create an instance of my object:
NewObject = new MyObject();
Within the constructor i want to be able to determine that the instance is called "NewObject":
function MyObject()
{
this.name = code_to_determine_my_name;
}
This should evaluate to MyObject.name == "NewObject"
I could of course pass the name as a parameter to the constructor but am trying to avoid this.
Anyone know how to accomplish this?
tnks in advance. lachlan@cynaptic.net