brother

原型链继承

耗尽温柔 提交于 2019-11-26 13:21:35
和原型继承有什么不同呢? 分别的用处是什么呢? 需要仔细体会 function Parent ( ) { this . name = 'mike' ; } function Child ( ) { this . age = 12 ; } Child . prototype = new Parent ( ) ; let child1 = new Child ( ) ; console . log ( child1 . age ) ; console . log ( child1 . name ) ; function Brother ( ) { this . weight = 60 ; } Brother . prototype = new Child ( ) ; let brother1 = new Brother ( ) ; console . log ( brother1 . weight ) ; console . log ( brother1 . age ) ; console . log ( brother1 . name ) ; 来源: https://blog.csdn.net/Andrew_Lii/article/details/98874066