Object.create方法创建一个使用原对象作为其原型的新对象。

 

1 if (typeof Object.create !== 'function') {
2     Object.create = function (o) {
3         function F() {}
4         F.prototype = o;
5         return new F();
6     };
7 }
8 newObject = Object.create(oldObject);

 


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-09-22
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2021-08-27
相关资源
相似解决方案