标签:
2015/4/2
1.Object.create
https://msdn.microsoft.com/zh-cn/library/ff925952
Animal = Object.create(Object); Animal.getName = function() { return this.name; }; Dog = Object.create(Animal); Dog.speak = function() { return "woof"; }; var dog = Object.create(Dog); dog.name = "Scamp"; console.log(dog.getName() + ‘ says ‘ + dog.speak());
我的理解:相当于是new的作用。但是比通过构造函数的方式创建对象来的慢(效率低)。
标签:
原文地址:http://www.cnblogs.com/barker/p/4387952.html