Why can't I browse __proto__ when creating an object?

When I create an empty object:

var o = {}; 

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

enter image description here


Edit: for completeness, to create a truly empty object (without prototype snapping), we could do:

 var o = Object.create(null); 

But for the purpose of the question, I will use the syntax o = {}.


Edit 2: This shows the prototype binding when creating the object, so there is __proto __, but I cannot view them with the debugger unless I add the function object.

enter image description here


Edit 3: It works in Firefox:

enter image description here

+5
source share
1 answer

Who knows? Apparently, this is a design decision by Chrome debugging developers. If someone here is not dedicated to the decision-making process, I think this question is not relevant to the topic.

They may have decided that you do not need to extend objects if they do not have methods.

Both IE and Firefox display the __proto__ property in their console even on empty objects. If you want to observe object prototypes for training purposes, it might be better to do this in one of these browsers.

+2
source

Source: https://habr.com/ru/post/1215084/


All Articles