lundi 23 avril 2018

in javaScript factory pattern i am not g undefined value

var peopleFactory = function (name,age,height){

var temp = {};

this.name = name;

this.age = age;

this.height = height;

temp.printPerson = function(){

console.log(this.name+''+this.age+''+this.height);

document.write(this.name+''+this.age+''+this.height);

};

return temp;

};

var person1 = peopleFactory('tanmay',27,5.11);

var person2 = peopleFactory('chinmay',37,5.12);

person1.printPerson();

person2.printPerson();

Aucun commentaire:

Enregistrer un commentaire