Hi,
I'm wondering if it's possible for an object to figure it's name.
for example:
function baseClass() {
// setup properties of "baseClass"
}
baseClass.proto type = {
aMethod: function() {
// do something using the name of the object
// that's an instance of this (or derived) class
// e.g.
// window.alert('m y name is: "' + DUNNO + '"');
};
};
function childOne() {
// setup properties of "childOne"
}
childOne.protot ype = new baseclass();
function childTwo() {
// setup properties of "childTwo"
}
childTwo.protot ype = new baseclass();
var o1 = new childOne(), o2 = new childTwo();
Now when calling "o1.aMethod ()" the "DUNNO" should be "o1" and the
same with "o2" respectively.
Is that possibly without having to force a "name" argument down the
inheritance tree?
--
Matthias
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST M$ ATTACHMENTS
/ \
I'm wondering if it's possible for an object to figure it's name.
for example:
function baseClass() {
// setup properties of "baseClass"
}
baseClass.proto type = {
aMethod: function() {
// do something using the name of the object
// that's an instance of this (or derived) class
// e.g.
// window.alert('m y name is: "' + DUNNO + '"');
};
};
function childOne() {
// setup properties of "childOne"
}
childOne.protot ype = new baseclass();
function childTwo() {
// setup properties of "childTwo"
}
childTwo.protot ype = new baseclass();
var o1 = new childOne(), o2 = new childTwo();
Now when calling "o1.aMethod ()" the "DUNNO" should be "o1" and the
same with "o2" respectively.
Is that possibly without having to force a "name" argument down the
inheritance tree?
--
Matthias
/"\
\ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
X - AGAINST M$ ATTACHMENTS
/ \
Comment