The [[Class]]
property of object is set according to how an object is created IIUC.
Is this why some objects are rendered to the Chrome console in a meaningful way e.g. MyFoo
and others are simply rendered as Object
?
With the new object literal syntax in ES6 for configuring the prototype chain. Can I modify the [[Class]]
property of the resulting object, so that it is rendered in a more meaningful way to the console?
var x = { __proto__: MyCtor.prototype };
console.log(x); // I want something like MyCtor to be logged to the console
I note that in Safari 8 on a Mac the above renders MyCtor
to the console. Chrome on the Mac does not.
PS: perhaps this is due to my confusing of browsers that support this prototype chain initialization syntax.