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