Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I view __proto__ upon object creation?

When I create a blank object:

var o = {};

Why can't I view the '__proto __' object when I create a new object, but I can when I add a function?

enter image description here


Edit: For completeness, to create a truly blank object (no prototypal linkage), we could do:

var o = Object.create(null);

But for the purposes of the question, I'll use the o = {} syntax.


Edit 2: This shows the prototype linkage upon a object creation, so the __proto's __ are there but I can't view them in the debugger unless I add a function object.

enter image description here


Edit 3: It works in Firefox:

enter image description here

like image 574
Data Avatar asked Mar 10 '15 19:03

Data


People also ask

How do you access object prototype?

Note: The property of an object that points to its prototype is not called prototype . Its name is not standard, but in practice all browsers use __proto__ . The standard way to access an object's prototype is the Object. getPrototypeOf() method.

What does __ proto __ in an object pointing to?

The __proto__ property is a default property added to every object. This property points to the prototype of the object. The default prototype of every object is Object. prototype .

Is __ proto __ deprecated?

__proto__ Deprecated: This feature is no longer recommended.

How do you create an object with prototype?

With Object.create() , we can create an object with null as prototype. The equivalent syntax in object initializers would be the __proto__ key. By default properties are not writable, enumerable or configurable.


1 Answers

Who knows? It appears to be a design decision on the part of the Chrome debugger's implementers. Unless someone here is privy to their decision process, I think this question is off topic.

Perhaps they figured that you didn't need to be able to expand objects unless they have methods.

Both IE and Firefox show the __proto__ property in their console, even on empty objects. If you want to observe object prototypes for learning purposes, perhaps it would be better to do so in one of those browsers.

like image 84
JLRishe Avatar answered Oct 16 '22 05:10

JLRishe