crop_rotate
Run
<!DOCTYPE html> <html> <body> <h2>JavaScript Object Constructors</h2> <p>You cannot add a new property to a constructor function.</p> <p id="demo"></p> <script> // Constructor function for Person objects function Person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } // You can NOT add a new property to a constructor function Person.nationality = "English"; // Create 2 Person objects const myFather = new Person("John", "Doe", 50, "blue"); const myMother = new Person("Sally", "Rally", 48, "green"); // Display nationality document.getElementById("demo").innerHTML = "The nationality of my father is " + myFather.nationality; </script> </body> </html>
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCjxib2R5Pg0KDQo8aDI+SmF2YVNjcmlwdCBPYmplY3QgQ29uc3RydWN0b3JzPC9oMj4NCg0KPHA+WW91IGNhbm5vdCBhZGQgYSBuZXcgcHJvcGVydHkgdG8gYSBjb25zdHJ1Y3RvciBmdW5jdGlvbi48L3A+DQoNCjxwIGlkPSJkZW1vIj48L3A+DQoNCjxzY3JpcHQ+DQoNCi8vIENvbnN0cnVjdG9yIGZ1bmN0aW9uIGZvciBQZXJzb24gb2JqZWN0cw0KZnVuY3Rpb24gUGVyc29uKGZpcnN0LCBsYXN0LCBhZ2UsIGV5ZSkgew0KICB0aGlzLmZpcnN0TmFtZSA9IGZpcnN0Ow0KICB0aGlzLmxhc3ROYW1lID0gbGFzdDsNCiAgdGhpcy5hZ2UgPSBhZ2U7DQogIHRoaXMuZXllQ29sb3IgPSBleWU7DQp9DQoNCi8vIFlvdSBjYW4gTk9UIGFkZCBhIG5ldyBwcm9wZXJ0eSB0byBhIGNvbnN0cnVjdG9yIGZ1bmN0aW9uDQpQZXJzb24ubmF0aW9uYWxpdHkgPSAiRW5nbGlzaCI7DQoNCi8vIENyZWF0ZSAyIFBlcnNvbiBvYmplY3RzDQpjb25zdCBteUZhdGhlciA9IG5ldyBQZXJzb24oIkpvaG4iLCAiRG9lIiwgNTAsICJibHVlIik7DQpjb25zdCBteU1vdGhlciA9IG5ldyBQZXJzb24oIlNhbGx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