moringaman
3/8/2017 - 11:46 PM

Passing functions to (object) constructor function

Passing functions to (object) constructor function

function Person(name, age, functn){
 this.name = name,
  this.age = age, 
 this.greet = functn
};

var person = new Person("Steve", 29, function(){
   console.log("hello my name is " + this.name + " and I am " + this.age);
 });

console.log(person);
person.greet();