So I was wondering if there is a way to use function.name
but for objects.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
What I mean by this is to have something like this:
function myFunction() {}
console.log(myFunction.name); // logs "myFunction"
// but like
var myObj = {};
console.log(myObj.name); // logs "myObj"
and if it is possible, how would it handle something like this?
var myObj = {};
var myObj2 = {};
console.log(myObj2.name); // logs "myObj" or "myObj2" or both?