Constructor patterns are used to define instance properties, and prototype patterns are used to define methods and shared properties. Benefit: Each instance has its own copy of the instance property, with a reference to the shared method, saving memory and supporting passing parameters to the constructor.
function Person (name,age,job) { this.name=name; This.age=age; This.job=job; this.friends=["Shelby", "Court"];} person.prototype={ Contructor:person, sayname:function () { alert (this.name); }} var person1=new person ("Nicholas", "Engineer"), var person2-new person ("Greg", "Doctor");p Erson1.friends.push (' "Van"); alert (person1.friends);//shely,count,van;alert (person2.friends);//shely,count;alert (person1.friends=== PERSON2.FRIEDNS);//false;alert (person1.sayname===person2.sayname);//true;
Appears to be the default pattern for defining reference types.
Function Creation Object (3) combination using constructor pattern and prototype mode