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?
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.
Edit 3: It works in Firefox:
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.
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 .
__proto__ Deprecated: This feature is no longer recommended.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With