Thursday, 5 September 2013

What am I doing wrong with this prototype setup?

What am I doing wrong with this prototype setup?

See the simplified code. What am I not getting with this pattern?
var john = new person('john');
john.hi();
function person(name) {
this.name = name;
}
person.prototype.hi = function() {
console.log('hi there. Name is ' + this.name);
};

No comments:

Post a Comment