Hi guys, I've got a JavaScript question which has me puzzled.  Can an
instance of a JavaScript object "know" the name of its instance?

 

That might not make any sense, so I have some quick sample code.
Consider the following:

 

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

 

customObject = function()

                        {

                        }

                        

customObject.prototype.whoAmI = function()

                        {

                                    return 'My instance name is ' + ??;

                        }

 

myObject = new customObject();

 

alert(myObject.whoAmI());

            

</SCRIPT>

 

What would I need to replace the "??" with to make the output say "My
instance name is myObject"?

this.something??

 

I don't even know if this is possible, but in theory I might have
several instances of the same object in the page and I want to know if
they can be "smart" enough to know which one they are.

 

~Brad



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create Web Applications With ColdFusion MX7 & Flex 2. 
Build powerful, scalable RIAs. Free Trial
http://www.adobe.com/products/coldfusion/flex2/

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271954
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to