# Object.create 实现原理
let newObj = Object.create(obj) 可以以 obj 为原型创建一个对象,这个对象继承 obj,同
 newObj.__proto__ = obj
function _create(obj) {
  function Fn() {}
  Fn.prototype = obj;
  return new Fn();
}
1
2
3
4
5
2
3
4
5
使用场景:封装继承方法
function inheritPrototype(sub, super) {
  let o = Object.create(super.prototype);
  o.constructor = sub;
  sub.prototype = o;
}
1
2
3
4
5
2
3
4
5
