When utilizing the web development tools console, if a browser object is typed, it will return as "console."
> console
Console { }
> console.log(console)
undefined
> Console { }
This behavior applies to all browser objects. However, when I try this with my own object, the output does not display the object name (MyObj) but rather just "Object" like this:
> var MyObj=function(){}
undefined
> var instance = new MyObj();
undefined
> instance
Object { }
> console.log(instance);
undefined
Object { }
Question:
Why is my output Object { }
instead of MyObj { }
?
NOTE: This is my second attempt at clarifying this question since the first one on js how to print the objectName to console was not successful. Please refrain from giving a simple response such as "write a toString() function," as that is not what I am looking for. I am seeking the SAME behavior not only in the toString (instance+'') output, but also in the "instance" output itself.