crop_rotate
Run
<!DOCTYPE html> <html> <body> <h2>JavaScript Object Constructors</h2> <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; } // Create 2 Person objects const myFather = new Person("Ali", "Ahmed", 50, "blue"); const myMother = new Person("Sally", "Rally", 48, "green"); // Add a name method to first object myFather.name = function() { return this.firstName + " " + this.lastName; }; // Display full name document.getElementById("demo").innerHTML = "My father is " + myFather.name(); </script> </body> </html>
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCjxib2R5Pg0KDQo8aDI+SmF2YVNjcmlwdCBPYmplY3QgQ29uc3RydWN0b3JzPC9oMj4NCg0KPHAgaWQ9ImRlbW8iPjwvcD4NCg0KPHNjcmlwdD4NCg0KLy8gQ29uc3RydWN0b3IgZnVuY3Rpb24gZm9yIFBlcnNvbiBvYmplY3RzDQpmdW5jdGlvbiBQZXJzb24oZmlyc3QsIGxhc3QsIGFnZSwgZXllKSB7DQogIHRoaXMuZmlyc3ROYW1lID0gZmlyc3Q7DQogIHRoaXMubGFzdE5hbWUgPSBsYXN0Ow0KICB0aGlzLmFnZSA9IGFnZTsNCiAgdGhpcy5leWVDb2xvciA9IGV5ZTsNCn0NCg0KLy8gQ3JlYXRlIDIgUGVyc29uIG9iamVjdHMNCmNvbnN0IG15RmF0aGVyID0gbmV3IFBlcnNvbigiQWxpIiwgIkFobWVkIiwgNTAsICJibHVlIik7DQpjb25zdCBteU1vdGhlciA9IG5ldyBQZXJzb24oIlNhbGx5IiwgIlJhbGx5IiwgNDgsICJncmVlbiIpOw0KDQovLyBBZGQgYSBuYW1lIG1ldGhvZCB0byBmaXJzdCBvYmplY3QNCm15RmF0aGVyLm5hbWUgPSBmdW5jdGlvbigpIHsNCiAgcmV0dXJuIHRoaXMuZmlyc3ROYW1lICsgIiAiICsgdGhpcy5sYXN0TmFtZTsNCn07DQoNCi8vIERpc3BsYXkgZnVsbCBuYW1lDQpkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiZGVtbyIpLmlubmVySFRNTCA9DQoiTXkgZmF0aGVyIGlzICIgKyBteUZhdGhlci5uYW1lKCk7IA0KPC9zY3JpcHQ+DQoNCjwvYm9keT4NCjwvaHRtbD4=