Edit This Code:
See Result »
<!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"); document.getElementById("demo").innerHTML = "My father is " + myFather.age + ". My mother is " + myMother.age; </script> </body> <!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_object_constructor by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 13 Mar 2016 11:03:04 GMT --> </html>
Result: