-1

What does the [[Prototype]]: Object string in the browser console (see pic) mean. As you can see from the code below:

({}).__proto__.__proto__ === null

the prototype chain consists of 2 links, but in the browser console for some reason my {} turned into [[Prototype]]: Object.

Browser log

Danko
  • 55
  • 2
  • 6
  • `let x = {}` gives, by default, an instance of `Object`. So by default, it will contain `toString` `hasOwnProperty` etc. Javascript non-primitives are usually instances of `Object`. That includes functions, so `let z = function(){}; z instanceof Object //true` – qrsngky Apr 07 '22 at 12:53
  • If [[Prototype]]: Object is Object.prototype, then why Object.prototype.__proto__ === null //true (1 step) and in the console (see pic) is the prototype chain consists of 2 links? – Danko Apr 07 '22 at 13:23

1 Answers1

0

[[Prototype]] is the name of the internal field of an object that says what that object's prototype is. The prototype is an object that is associated with every functions and objects by default in JavaScript, where function's prototype property is accessible and modifiable and object's prototype property (aka attribute) is not visible. The prototype object is special type of enumerable object to which additional properties can be attached to it which will be shared across all the instances of it's constructor function.

Ritik Banger
  • 2,107
  • 5
  • 25