e 1 год назад
Родитель
Сommit
7fea50c756
2 измененных файлов с 90 добавлено и 0 удалено
  1. 58 0
      JS高级/4.解构赋值.html
  2. 32 0
      JS高级/5.模板字符串.html

+ 58 - 0
JS高级/4.解构赋值.html

@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        var arr = [1,2,3];
+        var [a,b,c] = [1,2,3];
+        console.log(a,'a');
+        console.log(b,'b');
+        console.log(c,'c');
+
+        var str = 'vase';
+        var [x,y,z,e] = str;
+        console.log(x,'x');
+        console.log(y,'y');
+        console.log(z,'z');
+        console.log(e,'e');
+        
+        var obj = {
+            name: 'Lucy',
+            age: 18,
+            address:function() {
+                console.log("我的地址")
+            }
+        }
+
+        var {name,age,address} = obj;
+        // obj.address();
+        console.log(name);
+        console.log(age);
+        console.log(address);
+
+        // 形参
+        function fn1(name1,age1) {
+            console.log(name1,'函数1');
+            console.log(age1,'函数2')
+        }
+        // 实参
+        fn1({name1:'LiLi'},{age1:20});
+
+
+        function fn2() {
+            return {
+                name2:'小明',
+                age2: 23
+            }
+        }
+        var {name2,age2} = fn2();
+        console.log(name2,'name2');
+        console.log(age2,'age2');
+
+    </script>
+</body>
+</html>

+ 32 - 0
JS高级/5.模板字符串.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <script>
+        /**
+         * 模板字符串(template string)
+         * 使用反引号(`)
+        */
+        /**
+         * 1.允许使用换行符;
+         * 2.输出模板:`...${xxx}...`;
+        */
+        let str = `
+            <ul>
+                <li>1</li>    
+                <li>2</li>    
+                <li>3</li>    
+            </ul>
+        `
+        document.write(str);
+        let name = '图图';
+        // let result = '我的名字是' + name;
+        let result = `我的名字是${name}`;
+        console.log(result);
+    </script>
+</body>
+</html>