M
Mike McCollister
I am trying to do what is most likely impossible. In JavaScript I want to
know the variable name that a new object is assigned to from within the
object. For example, if I do this
var testObject = new TestObject();
then the TestObject object will, with some magic function, get the
assignment variable name which in the above case is "testObject". I'm
thinking that the caller or callee property might be of use.
function TestObject()
{
// constructor
{
// constructor stuff here
var html = "";
var assignmentName = SomeMagicFunction(); // ??? where's the magic
html += "<img onClick='" + assignmentName + ".DoThisFunction()'>";
document.writeln(html);
}
}
If this is impossible, I'll just pass the assignee name as a parameter to
the object. Just wanting to make the object as smart as possible.
Thanks,
Mike
know the variable name that a new object is assigned to from within the
object. For example, if I do this
var testObject = new TestObject();
then the TestObject object will, with some magic function, get the
assignment variable name which in the above case is "testObject". I'm
thinking that the caller or callee property might be of use.
function TestObject()
{
// constructor
{
// constructor stuff here
var html = "";
var assignmentName = SomeMagicFunction(); // ??? where's the magic
html += "<img onClick='" + assignmentName + ".DoThisFunction()'>";
document.writeln(html);
}
}
If this is impossible, I'll just pass the assignee name as a parameter to
the object. Just wanting to make the object as smart as possible.
Thanks,
Mike