12345678910111213141516171819202122 |
- <header>Person Constructor</header>
- <body>
- <script>
- function createPerson(name, surname) {
- this.name = name;
- this.surname = surname;
- this.getFullName = () => {
- return `${this.name} ${this.surname}`;
- }
- }
- const a = new createPerson("Вася", "Пупкин")
- const b = new createPerson("Анна", "Иванова")
- const c = new createPerson("Елизавета", "Петрова")
- console.log(a.getFullName())
- a.fatherName = 'Иванович'
- console.log(b.getFullName())
- </script>
- </body>
|