js prototype and __proto__ full picture
2018-04-09 17:32:44 0 举报
prototype VS __proto__ deep dive version
作者其他创作
大纲/内容
reference constructor
Sarahclass Z extends nullCANNOT instantiate!
reference __proto__
null
functions
AdamObject.prototype
subclasses
reference prototype
Jesusfunction Object
class A {}A.idA = 'class A';class B extends A{}B.idB = 'class B extends A';var prototypeOfA = A.prototype;prototypeOfA.idAp = 'A.prototype';var prototypeOfB = B.prototype;prototypeOfB.idBp = 'B.prototype';var instanceOfB = new B();instanceOfB.idBi = 'B.instance';var assert = console.assert;assert(B.__proto__ === A);assert(B.prototype.__proto__ === A.prototype); assert(instanceOfB.__proto__ === B.prototype); assert('idBp' in instanceOfB);assert('idAp' in instanceOfB);assert('idA' in B);
when new B()
Yehovahfunction Function
object B.prototype{idBp: 'B.prototype'}
classes
object A.prototype{idAp: 'A.prototype'}
objects
class Afunction A(){idA: 'class A'}
Z.prototype
class B extends Afunction B(){idB: 'class B ext. A'}
object instanceOfB{idBi: 'instanceof B}
EveFunction.prototypefunction f() {...}
0 条评论
下一页