Visibility of a property of a function prototype against an object on the console

When we define these variables in the console:

var a = function(){} ;
var b = {} ;
var c = new a();

and enter the following expressions again on the console:

a.prototype 
// we have an a object with properties constructor and __proto__
b.prototype
// no result and why ? Isn t the prototype the Object 
c.prototype
// no result here too.

Therefore, I know that almost every type in js is an object and has a prototype of a global object. Why do not we see the last two properties of the prototype? Is it about property descriptors or what? I just assume he has a simple answer.

+4
source share
2 answers

A property with a name .prototypeis a property of a constructor function only. It is stored elsewhere for the actual instance of the object and is not available as .prototypeit is.

Object.getPrototypeOf(obj) . . MDN.

obj.__proto__.


. , , . Javascript , . , , , , - , .

, . - . , .

++ ( , - ), , . , .

+2

, , JavaScript . , , prototype.

? , . , , . ECMAScript, [[Prototype]] .

__proto__, [[Prototype]], , .

ES6 : Object.getPrototypeOf().

, instanceof. __proto__ prototype.

+1

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


All Articles