Gennadysht %!s(int64=2) %!d(string=hai) anos
pai
achega
fc7f47b29d

+ 17 - 0
js/11/hw11_01_create_person.html

@@ -0,0 +1,17 @@
+<head>create person</head>
+
+<body>
+    <script>
+        function getFullName(/*this*/) { //никаких this тут объявлять не надо, они подразумеваются
+            return `${this.name} ${this.surname}`
+        }
+        const a = createPerson("Вася", "Пупкин")
+        const b = createPerson("Анна", "Иванова")
+        const c = createPerson("Елизавета", "Петрова")
+
+        console.log(a.getFullName()) //Вася Пупкин
+        a.fatherName = 'Иванович'    //Вася Иванович Пупкин
+
+        console.log(b.getFullName()) //Анна Иванова
+    </script>
+</body> 

+ 13 - 0
js/11/hw11_02_createPersonClosure.html

@@ -0,0 +1,13 @@
+<head>createPersonClosure</head>
+<body>
+    <script>
+        const a = createPersonClosure("Вася", "Пупкин")
+const b = createPersonClosure("Анна", "Иванова")
+console.log(a.getName())
+a.setAge(15)
+a.setAge(150) //не работает
+
+b.setFullName("Петрова Анна Николаевна")
+console.log(b.getFatherName()) //Николаевна
+    </script>
+</body>

+ 9 - 0
js/11/hw11_03_create person destruct.html

@@ -0,0 +1,9 @@
+<head>createPersonClosureDestruct</head>
+
+<body>
+    <script>
+        const a = createPersonClosureDestruct(createPerson("Вася Пупкин"))
+        const b = createPersonClosureDestruct({ name: 'Николай', age: 75 })
+
+    </script>
+</body>