I want to get the current instance name from within that same instansiated function.
function MyFunction() {
this.prop1 = 1;
this.prop2 = 2;
alert("My instance name: " + MyFunction.caller + "?"
;
}
var newFunc1 = new MyFunction();
var newFunc2 = new MyFunction();
===================================
The result should be:
"My instance name: newFunc1?"
"My instance name: newFunc2?"
===================================
The result is:
"My instance name: null?"
"My instance name: null?"
===================================
Can this be done somehow. Caller is not working as I expected. Is there some other way?
function MyFunction() {
this.prop1 = 1;
this.prop2 = 2;
alert("My instance name: " + MyFunction.caller + "?"
}
var newFunc1 = new MyFunction();
var newFunc2 = new MyFunction();
===================================
The result should be:
"My instance name: newFunc1?"
"My instance name: newFunc2?"
===================================
The result is:
"My instance name: null?"
"My instance name: null?"
===================================
Can this be done somehow. Caller is not working as I expected. Is there some other way?