I am trying to add prototype to already created object Instance (Person1) in this example, but it is not getting successfully added, and thereby giving error. Can someone help me out?
<html>
<head></head>
<body>
<script>
var person = function(name, age){
this.name = name;
this.age = age;
this.printName = function(){
alert(this.name);
}
}
person.prototype.printAge = function(){
alert(this.age);
}
var person1 = new person("Jack", 29);
person1.prototype.printMessage = function(){
alert("Hello Friend");
}
var person2 = object.create(person1);
person2.printName();
person2.printAge();
person2.printMessage();
</script>
</body>
</html>