Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> function person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } var myFather = new person("John", "Doe", 50, "blue"); var myMother = new person("Sally", "Rally", 48, "green"); myFather.name = function() { return this.firstName + " " + this.lastName; }; document.getElementById("demo").innerHTML = "My father is " + myFather.name(); </script> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_object_prototype8 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:36:17 GMT --> </html>
Result:
Try it Yourself - © w3schools.com