moringaman
3/7/2017 - 7:01 PM

Constructor Function

Constructor Function

function Person(){
 this.name = "David",
 this.greet = function(){
   console.log("hello my name is " + this.name);
 }
}

var person = new Person();
person.name =  "johnny";
console.log(person);

var newPerson = new Person();
newPerson.name = "Sally";

var defaultPerson = new Person();

person.greet();
newPerson.greet();
defaultPerson.greet();