fengchuanyu 1 hari lalu
induk
melakukan
b9d59d4be1

TEMPAT SAMPAH
.DS_Store


+ 2 - 2
6_HTML5/9_历史管理history.html

@@ -22,8 +22,8 @@
         }
 
         // hash 和 history 区别
-        // hash 是url的片段 
-        // history 是浏览器的历史记录 
+        // hash 是url的片段 地址中会有一个#XXXX 
+        // history 是浏览器的历史记录 在地址栏中没有体现
     </script>
 </body>
 </html>

+ 1 - 1
7_移动端/4_max&min.html

@@ -13,7 +13,7 @@
             /*max-width控制元素最大值  最大宽度为1000px */
             /* 当前屏幕大于1000px 元素宽度为1000px 小于1000px 元素宽度为当前屏幕宽度 */
             max-width: 1000px;
-
+            /*min-width控制元素最小值  最小宽度为300px */
             min-width: 300px;
             background-image: url("./img/img1.jpg");
             background-size: 100% 100%;

+ 27 - 0
8_ES6/12_Symbol.html

@@ -0,0 +1,27 @@
+<!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>
+        // Symbol
+        let username = Symbol();
+
+        let obj = {
+            age:18,
+            school:"xxx大学",
+            // username:"李四"
+        }
+        obj[username] = "张三"
+        // obj.username = "张三"
+        console.log(obj);
+        // 获取Symbol属性值
+        console.log(obj[username]);
+
+        // Symbol 一般用作于对象的属性名 防止属性名冲突
+    </script>
+</body>
+</html>

+ 68 - 0
8_ES6/13_对象扩展.html

@@ -0,0 +1,68 @@
+<!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>
+        // let objVal = "age";
+        // let age = 18;
+        // 如果对象中属性名和变量名相同 可以直接写属性名 不需要写 :变量名
+        // 对象中定义方法可以直接写方法名 不需要写 :function
+        // let obj = {
+        //     age,
+        //     school:"xxx大学",
+        //     username:"李四",
+        //     talk(){
+        //         console.log("我在说话");
+        //     }
+        // }
+        // obj.objVal = 18;
+
+        // 动态添加属性 可以使用变量来添加属性 写在[]内 []内可以写一写简单的表达式
+        // obj[objVal] = 18;
+        // obj[objVal+"2"] = 20;
+        // console.log(obj);
+
+
+        let obj2 = {
+            age:20,
+            school:"xxx大学"
+        }
+
+        let obj3 = {
+            age:20,
+            school:"xxx大学"
+        }
+        let obj4 = obj3;
+
+        let a = "hello";
+        let b = "hello";
+        // Object.is 判断的是栈内存中的值
+        // console.log(Object.is(a,b));
+        // console.log(obj2 == obj3);
+
+        let obj5 = {
+            username:"张三",
+            age:30
+        }
+        // 对象的一个合并 最前面的对象作为接收方 会把后边所有对象的属性合并到第一个对象中 
+        // 如果对象有属性冲突后边对象会覆盖前边对象的属性
+        Object.assign(obj2,obj5);
+        console.log(obj2);
+        // in 判断对象中是否包含指定的属性 判断的属性需要加""
+        // console.log("age2" in obj5);
+
+        // for ... in 可以遍历对象 默认遍历值是 属性名
+        for( let keys in obj2 ){
+            console.log(keys);
+            console.log(obj2[keys]);
+        }
+
+        // keys() 可以把对象中所有属性名拼合成数组返回
+        console.log(Object.keys(obj2));
+    </script>
+</body>
+</html>

+ 2 - 0
8_ES6/1_let&const.html

@@ -38,6 +38,8 @@
         // console.log(b);
 
 
+        // let 定义的变量 不会挂载到 window 对象上
+        // var 定义的变量 会挂载到 window 对象上
         var a = 10;
         let b = "hello";
         console.log(window.a);

+ 2 - 0
8_ES6/4_块作用域.html

@@ -12,6 +12,8 @@
         // }
         // console.log(a);
 
+        // let 存在块作用域 
+        // 块作用域:在{}内的代码就是块作用域
         if(true){
             let a = 10;
         }

+ 4 - 4
8_ES6/8_数组扩展.html

@@ -99,10 +99,10 @@
         //     console.log(value);
         // }
 
-        // entries() 返回数组中每一个值的索引和值
-        for(let item of arr.entries()){
-            console.log(item);
-        }
+        // entries() 返回数组中每一个值的索引和值 会将索引和值封装成一个数组返回 第一个元素是索引 第二个元素是值
+        // for(let item of arr.entries()){
+        //     console.log(item);
+        // }
     </script>
    
 </body>

+ 0 - 0
8_ES6/练习2_数组去重.html


+ 52 - 0
8_ES6/练习题2_数组去重.html

@@ -0,0 +1,52 @@
+<!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,1,1,1,2,3,4,5,2,6,7,1];
+        // // 数组去重方法一
+        // for(var i = 0;i<arr.length;i++){
+        //     for(j = i+1;j<arr.length;j++){
+        //         if(arr[i] == arr[j]){
+        //             arr.splice(j,1);
+        //             j--;
+        //         }
+        //     }
+        // }
+        // console.log(arr);
+
+
+        // 数组去重方法二 利用indexOf方法
+        // let arr = [1,2,3,1,1,1,2,3,4,5,2,6,7,1];
+        // let newArr = [];
+        // for(let i=0;i<arr.length;i++){
+        //     if(newArr.indexOf(arr[i])==-1){
+        //         newArr.push(arr[i]);
+        //     }
+        // }
+        // console.log(newArr);
+
+        // 数组去重方法三 利用对象属性唯一的特性
+        // let arr = [1,2,3,1,1,1,2,3,4,5,2,6,7,1];
+        // let obj = {};
+        // for(let i=0;i<arr.length;i++){
+        //     if(arr[i] in obj){
+        //         obj[arr[i]]++
+        //     }else{
+        //         obj[arr[i]] = 1;
+        //     }
+        // }
+        // console.log(Object.keys(obj));
+
+        // 数组去重方法四 利用ES6的Set数据结构
+        let arr = [1,2,3,1,1,1,2,3,4,5,2,6,7,1];
+        let newArr = new Set(arr);
+        console.log(Array.from(newArr));
+        
+    </script>
+</body>
+</html>