Prev Demo
Adding Properties To A Existing Prototype In Javascript Object-Oriented Programming.
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Adding properties to a existing Prototype</h1> <p id="myId"></p> <script> function person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } person.prototype.native = "Madanapalli"; var myFriend = new person("Charitha", "Reddy", 23, "blue"); document.getElementById("myId").innerHTML = "My friend is from " + myFriend.native; </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output