Prev Demo
JavaScript
>
Prototype
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Creating Prototype</h1> <p id="myId"></p> <script> function person(first, last, gender, height) { this.firstName = first; this.lastName = last; this.gender = gender; this.height = height; } var myFriend = new person("Charitha", "Goud", "Female", 5.3); var myColleague = new person("Surendra", "Goud", "Male", 5.8); var myResult = "Charitha is: " + myFriend.gender + "<br>" + "Surendra is: " + myColleague.gender; document.getElementById("myId").innerHTML = myResult; </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output