hw14_01_person_constructor.html 631 B

12345678910111213141516171819202122
  1. <header>Person Constructor</header>
  2. <body>
  3. <script>
  4. function createPerson(name, surname) {
  5. this.name = name;
  6. this.surname = surname;
  7. this.getFullName = () => {
  8. return `${this.name} ${this.surname}`;
  9. }
  10. }
  11. const a = new createPerson("Вася", "Пупкин")
  12. const b = new createPerson("Анна", "Иванова")
  13. const c = new createPerson("Елизавета", "Петрова")
  14. console.log(a.getFullName())
  15. a.fatherName = 'Иванович'
  16. console.log(b.getFullName())
  17. </script>
  18. </body>