Does object.create change console output of proto object in chrome?

I played today when I noticed that some of my objects in the Chrome console display as Object instead of the constructor function name.

It was weird, so I flipped it to the following code:

 function Baz() { this.baz = true; } var b = new Baz(); var c = Object.create(b); console.log(b); // why is b outputting with Object not Baz? 

In the above code, b not created using Object.create , but when registering, it says Object. I don't have typos and mistakenly ask about c. . The log b was changed when I did not even touch this object. Creating another instance of c should not be modified b .

Is this a Chrome bug? Is there a way to get Chrome to correctly tell Baz here?

This is important for debugging purposes.

enter image description here

UPDATE Error: https://code.google.com/p/chromium/issues/detail?id=478522

+7
javascript google-chrome object-create
source share
1 answer

Update: this is truly a regression between Chrome 41 and Chrome 42. Tracked here: http://crbug.com/478522

Chrome 41 output: enter image description here

Chrome 42 Output:

They made syntax highlighting improvements when entering dev tools, and that probably broke. I ping a friend who is deeply involved with dev tools. Nice to find.


Not. The problem you are describing is very real.

Objects created using constructors will be displayed when they are registered and, as a rule, are better debugged in Chrome (and in node / io.js).

For this reason, I avoid Object.create for prototypical inheritance in my own code, although I prefer it conceptually.

I think you understand this, but I still want to clarify for future readers. Note that inheritance is still happening with the version of Object.create . The only difference is how the object is registered and processed in the debugger.

+5
source share

All Articles