Javascript examples for Object:prototype
object with prototype
function Person(name, surname) { this.name = name;/*from w w w . j a v a 2 s. c o m*/ this.surname = surname; // this.fullName2 = function() { return this.name + " - 2 - " + this.surname; } //*/ } Person.prototype.fullName = function() { return this.name + " " + this.surname; } var bart = new Person("Bart", "Simpson"); bart.age = 12; console.log(bart.constructor); console.log(bart.constructor.prototype); console.log(bart); console.log(bart.name); console.log(bart.fullName()); console.log(bart.fullName2()); bart.fullName = function() { return bart.constructor.prototype.fullName.call(this); }; console.log(bart);