In the process of developing a JavaScript app, I am utilizing a third-party library which defines an object in the following structure:
getLibrary().SomeObject = function() {
function SomeObject(attrs) {
this.id = attrs.id;
this.description = attrs.description || '';
this.result = {
id: this.id,
description: this.description,
};
}
SomeObject.prototype.doSomething = function(actual) {
return 'do something';
};
SomeObject.prototype.calculate = function() {
return 42;
};
return SomeObject;
};
I have created an instance of this object stored in a variable named myInstance
. When reviewing the Chrome console output using console.log(myInstance)
, the displayed content is as follows:
v SomeObject
id: '1'
description: 'my description'
> result: Object
My objective is to extract the "SomeObject" part from the output above. Attempting to use the instanceof
check with SomeObject
did not yield the desired outcome. Essentially, I am seeking a way to retrieve the name of the "type" or function associated with myInstance
.
Any assistance on how to achieve this would be greatly appreciated.