Chrome Javascript console: what does it display in terms of objects?

From javascript console in Chrome:

> function Person(name){this.name=name;}
undefined

At this point, Person.prototype should be an empty object according to Javascript specifications. Let appoint him:

> p=Person.prototype
  > Person

Please note that this> Person is clickable, and it expands to:

constructor: function Person(name){this.name=name;}
__proto__: Object

But ... doesn't that mean it's an empty object? What is this additional material? If you make a warning:

alert(p)

You get [Object Object]. Why, when you enter it into the Chrome console, does it go out s> Face that expands? Doesn't that mean it's an empty object?

Thank!

+3
source share
3 answers

, prototype constructor, , . , , , __proto__.

ECMAScript 5 13.2, :

(...)

16. proto , new Object(), Object .

17. [[DefineOwnProperty]] "constructor", {[[]]: F, {[[ Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true} false.

18. [[DefineOwnProperty]] F "prototype", {[[]]: proto, {[[ Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false} false.

(...)

:

proto (16). constructor F ( ) (17). prototype F proto.


alert , . [object Object], "" toString .

Chrome , , . [object Object] .

FWIW, :

empty object

__proto__. , .

+10

Chrome - . . , .

0

, Object.

0

All Articles