Gennadysht преди 2 години
родител
ревизия
fc7f47b29d
променени са 3 файла, в които са добавени 39 реда и са изтрити 0 реда
  1. 17 0
      js/11/hw11_01_create_person.html
  2. 13 0
      js/11/hw11_02_createPersonClosure.html
  3. 9 0
      js/11/hw11_03_create person destruct.html

+ 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>