I would like to ask why the last instance2.test result in the following set of prototype chain code is h _ 1, br, h _ 2, h _ 3, and h _ 4?
hasn"t an h5 already been push before
?
I would like to ask why the last instance2.test result in the following set of prototype chain code is h _ 1, br, h _ 2, h _ 3, and h _ 4?
hasn"t an h5 already been push before
?
test
is an instance attribute of the subclass SubType
. When var instance2=new SubType ()
, assign test
of instance2
to ["H1", "H2", "h3", "h4"]
. Similarly, when you instance1.test.push
, you also modify the instance properties of instance1
.
when you visit instance2.name
, you can't find the instance property. Then go to the prototype chain and find that SubType.prototype
has the attribute name
, so return it. Similarly, instance1.name.push
also modifies the name
attribute of the prototype chain SubType.prototype
.
Previous: Nginx is configured but cannot be accessed through a domain name
Next: How to check whether kibana and elsasticsearch-head services are started
Code: <script> function Dog(){} var dog = new Dog(); var dog1 = Object.create(dog); console.log(dog1._proto_); console.log(Object.getPrototypeOf(dog1)); < script> ...