Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 375 Bytes

2.extends.md

File metadata and controls

17 lines (14 loc) · 375 Bytes
extends作为 ES6 语法的关键字,只能定义为函数

const _extends = function(SubType, SuperType){
    
    SubType.prototype = Object.create(SuperType.prototype,{
        constructor:{
            value:SubType,
            writable:true
        }
    });

Object.setPrototypeOf?
  Object.setPrototypeOf(SubType,SuperType):
  SubType.__proto__=SuperType;
}