Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的__proto__。

举个小例子 就知道了

var obj={
                say:function(){
                    console.log('hello world');
                },
                sleep:function(){
                    console.log('我可以睡觉!')
                }
            }
            var person=Object.create(obj);
            person.name="小王"
            console.log(person);
            person.say();
            person.sleep()

扫除个知识盲点,Object.create方法的使用

相关文章:

  • 2021-10-29
  • 2021-11-27
  • 2021-11-25
  • 2021-08-06
  • 2021-12-19
  • 2021-12-03
  • 2022-01-09
猜你喜欢
  • 2021-10-03
  • 2021-06-13
  • 2021-08-29
  • 2021-12-04
  • 2021-12-05
  • 2021-04-29
  • 2021-12-01
相关资源
相似解决方案