I've created a JavaScript Class just as following:
function MyClass() {
this.myProp = '';
}
MyClass.prototype.myTestFunction = function() {
alert('test');
}
Now, I instantiate this class.
var myTestInstance = new MyClass();
myTestInstance.myTestFunction();
This outputs an alert with 'test'.
Now I want to have the variable name 'myTestInstance' into the function 'myTestFunction()' without having to pass it as a parameter.
Is it somehow possible to find out the variable name of the instance from inside the called function?
Thank you for your help!
EDIT: Just to add information why I would need this: Every instance I create in my real project is a special HTML table. In the header fields are sort-buttons for every column. Therefore I added dynamically a link-element with href='javascript:myTableInstance.sort()'. To print this dynamically IN the instance, I needed the variable name.
Would there be another, better solution?