Why do new and object.create behave differently in this example
问题 In this simple example, why do new and Object.create behave differently? var test=function(name){ this.name=name }; var test1= new test("AAA"); test1.name;//AAA var test2=Object.create(test); test2.name="AAA"; typeof(test2);//Object test2.name;//"" (empty string). Why is test2.name empty? 回答1: Object.create expects an Object as it's first argument for the prototype chain, not a function (or constructor in your case). It won't complain if you pass a function , but it means that certain extra