1.深拷贝
//深拷贝 function deepCopy(obj) { let newObj = Array.isArray(obj) ? [] : {} for (const key in obj) { if (Object.hasOwnProperty.call(obj, key)) { if (typeof obj[key] == 'object') { newObj[key] = deepCopy(obj[key]) } else { newObj[key] = obj[key]; } } } return newObj }
Son.prototype = Dad.prototype
2.组合继承
let Link = function(){} Link.prototype = Dad.prototype Son.prototype = new Link() Son.prototype.constructor = Son