The last discussion about the inherit

point about inherit:

  1:subclass can get SuperClass`s message

  2:subclass rewrite SuperClass`s message

  3:many subclass Share a piece of memory

the inherit plan in javascript

  1:subClass get superClass by __proto__

  2:subClass can reWrite superClass

  3:when subClass initialize,is must initialize superClass by call

  

the principle about instence

扫描二维码关注公众号,回复: 7049308 查看本文章

  current instence keeping find the attrbute by __proto__,such as:

  

var a = new A();
a instence Object?

  1:a.__proto__ != Object.prototype

  2:a.__proto__ -> A.prototype so we judge:A.prototype.__proto__ == Object.protype

  so a.__proto__.__proto__ == Object.protype, so a instence A is true

猜你喜欢

转载自www.cnblogs.com/mrzhu/p/11369652.html