fengchuanyu hace 8 meses
padre
commit
4a27319e9c
Se han modificado 2 ficheros con 74 adiciones y 0 borrados
  1. 26 0
      5_ES6/21_symbl.html
  2. 48 0
      5_ES6/22_set.html

+ 26 - 0
5_ES6/21_symbl.html

@@ -0,0 +1,26 @@
+<!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 obj = {
+            a:1,
+            b:2
+        }
+        let sym = Symbol();
+        // console.log(sym)
+        obj[sym] = "hello";
+        // console.log(obj)
+        // console.log(obj[sym]);
+
+        for(let k in obj){
+            console.log(k)
+        }
+        console.log(Object.keys(obj))
+    </script>
+</body>
+</html>

+ 48 - 0
5_ES6/22_set.html

@@ -0,0 +1,48 @@
+<!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 s1 = new Set();
+        // s1.add(1);
+        // s1.add("hello");
+        // console.log(s1)
+        // let s2 = new Set([1,2,3,4,5]);
+        // s2.add(3);
+        // s2.add(6);
+        // console.log(s2);
+
+        // let arr = [1,2,3,4,5,6,3,4,5];
+        // let s3 = new Set(arr);
+        // console.log(s3);
+        // console.log(Array.from(s3));
+
+
+        // let s4 = new Set([1,2,3,4,5]);
+        // s4.delete(3);
+        // console.log(s4)
+        // console.log(s4.has(5));
+        // s4.clear();
+        // console.log(s4);
+
+        // for(let val of s4.entries()){
+        //     console.log(val);
+        // }
+        // console.log(s4.size);
+
+        let obj = {
+            b:2
+        }
+        let ws = new WeakSet();
+        ws.add({a:1});
+        ws.add(obj);
+        // ws.add(1);
+        ws.add(obj);
+        console.log(ws)
+    </script>
+</body>
+</html>