javascript - Js method to create objects
迷茫
迷茫 2017-05-19 10:25:57
0
1
511

The advanced tutorial mentioned that methods for creating objects include literal method, factory mode, constructor mode, prototype mode, mixed mode, etc. There is an example in the factory pattern,

function  creatPerson(name){
   var  obj=new Object();
   obj.name=name;
   return  obj;
}
var person=creatPerson(“hello”);

The constructor pattern has been used inside the function, so why is the factory pattern still present? Are these methods of creating objects developed step by step? Is the prototype attribute of a function only for the prototype mode, or has it existed since the birth of JavaScript? Can anyone tell me the history?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!