M
Matthias Watermann
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.prototype = {
aMethod: function() {
// do something using the name of the object
// that's an instance of this (or derived) class
// e.g.
// window.alert('my name is: "' + DUNNO + '"');
};
};
function childOne() {
// setup properties of "childOne"
}
childOne.prototype = new baseclass();
function childTwo() {
// setup properties of "childTwo"
}
childTwo.prototype = 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.prototype = {
aMethod: function() {
// do something using the name of the object
// that's an instance of this (or derived) class
// e.g.
// window.alert('my name is: "' + DUNNO + '"');
};
};
function childOne() {
// setup properties of "childOne"
}
childOne.prototype = new baseclass();
function childTwo() {
// setup properties of "childTwo"
}
childTwo.prototype = 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
/ \