The code is simple.

var now = new Date();
console.log(now.__proto__);
console.log(now.__proto__.__proto__);
console.log(now.__proto__.__proto__.__proto__);

In the console of Chrome, the result is shown as the screenshot.

enter image description here

The result seems correct in the console of Node.js.

enter image description here

Why doesn't now.\__proto\__ return Date {} in Chrome's console?

1

There are 1 best solutions below

0
On BEST ANSWER

It's just a rendering, for which there's no specification.

Node does more computation to return the name of the constructor of the object whenever possible.

If you want to see it in the source, it's a little tedious to read because there are many different cases but it's basically in the formatValue function which is called by util.inspect.