A question about scope chain in JavaScript, the difference between prototype and _ _ prototype _?

  javascript

Please look at the code

Code one

<script type="text/javascript">
 
 var animal = function(){};
 var dog = function(){};
 
 animal.price = 2000;
 dog.__proto__ = animal;
 var tidy = new dog();
 
 console.log(dog.price) //2000
 console.log(tidy.price) // undefined
 
 </script>

Code 2

<script type="">
 
 var animal = function(){};
 var dog = function(){};
 
 animal.price = 2000;
 dog.prototype = animal;
 var tidy = new dog();
 
 console.log(dog.price) //undefined
 console.log(tidy.price) // 2000
 
 </script>

Why is the result the opposite?

What is the inheritance based on prototype chain in JavaScript?

__proto__It is the instance (such as tidy) that accesses the prototype object while it is nonstandard. the ES5 standard method isObject.getPrototypeOf()
prototypeIs the constructor (such as Dog) accessing the prototype object

This can be verified

function Dog() {}
 var tidy = new Dog();
 
 //They refer to the same memory address, which is their prototype.
 tidy.__proto__ === Dog.prototype

However, inheritance based on prototype chain is not reflected here.

function Dog() {}
 function Animal() {}
 
 //Implement prototype chain inheritance
 Dog.prototype.__proto__ = Animal.prototype;
 
 var tidy = new Dog();
 
 // tidy's prototype points to Dog.prototype
 tidy.__proto__ === Dog.prototype
 
 //because dog.prototype. _ _ prototype _ _ = = = animal.prototype
 //the prototype of tidy's prototype (forming a prototype chain) points to Animal.prototype
 tidy.__proto__.__proto__ === Animal.prototype
 
 //The terminal of prototype chain is Object.prototype
 tidy.__proto__.__proto__.__proto__ === Object.prototype
 
 //Further on is null
 tidy.__proto__.__proto__.__proto__.__proto__ === null