0
JavaScript
What is the difference between factory pattern vs constructor pattern ???
2 Respostas
0
factory pattern just hide the object creation logic ..so u just call the factory method to create the object..
0
function Constructor() {}
function factory() {
return new Constructor();
}
var obj1 = new Constructor();
var obj2 = factory();
/*
factory pattern spare the required use of 'new' before constructor function to create an object...
in both above cases, same object kind is returned in obj1 and obj2 (both have same constructors)
*/