一、Object.create 和 new Object
1. const newObj = Object.create(obj) 使用 obj 作为新对象 newObj 的原型对象 ,可以用 Object.create(null)来创建一个没有原型的对象。
2. const newObj = new Object() 和 newObj = {} 创建的对象都默认继承 Object.prototype。Object.prototype === {}.__proto__
3.Object.setPrototypeOf(newObj, null) 可以将 newObj 的原型置为 null
二、prototype 和 constructor
1. [].__proto__ === Array.prototype
2. Array.prototype.constructor === Array
3. [].constructor === Array
4. 数组方法挂在Array.prototype对象上,数组实例可以访问到这些方法。 const arrayMethods = Object.create(Array.prototype); 创建了一个原型对象为Array.prototype的空对象,也能通过 arrayMethods[methodName] 访问数组方法。
三、【ImageUpload】继承【FileUploadBaseClass】的一些方法

四、ES6 类与继承

网友评论