This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.
Smartphone icons created by Freepik - Flaticon
// Constructor function for Person objects function Person(first, last, age, eye, nationality) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; this.nationality = nationality; } // Create 2 Person objects const myFather = new Person("John", "Doe", 50, "blue", "Canadian"); const myMother = new Person("Sally", "Rally", 48, "green", "English"); // Display nationality document.getElementById("demo").innerHTML = "My father is " + myFather.nationality + ". My mother is " + myMother.nationality;
Object properties can have default values. However, the default value applies to all person objects.