fengchuanyu hace 4 meses
padre
commit
be18fa14f0

+ 47 - 0
6_ES6/29_Generator.html

@@ -0,0 +1,47 @@
+<!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>
+        // function* foo(){
+        //     console.log('start');
+        //     yield;
+        //     console.log("1");
+        //     yield;
+        //     console.log("2");
+        // }
+        // let g = foo();
+        // g.next();
+        // g.next();
+        // g.next();
+
+        // function* foo(){
+        //     let a = 1;
+        //     let b = yield a + 3;
+        //     console.log(111);
+        //     console.log(b);
+        // }
+        // let g = foo();
+        // let {value} =g.next();
+        // console.log(g.next(value));
+
+        // function* foo(x) {
+        //     var y = 2 * (yield (x + 1));
+        //     console.log(y);
+        //     var z = yield (y / 3);
+        //     return (x + y + z);
+        // }
+        // let foo2 = foo(1);
+        // console.log(foo2.next());
+        // console.log(foo2.next(3));
+        // console.log(foo2.next(1));
+
+
+
+    </script>
+</body>
+</html>

+ 23 - 0
6_ES6/30_严格模式.html

@@ -0,0 +1,23 @@
+<!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>
+        "use strict"
+        // 严格模式
+        // var a = 10;
+        // var a = "hello";
+        // console.log(a);
+        // a=10;
+        var a = 10;
+        function foo(){
+            console.log(this.a);
+        }
+        foo();
+    </script>
+</body>
+</html>

+ 3 - 0
6_ES6/babel/.babelrc

@@ -0,0 +1,3 @@
+{
+    "presets": ["env"]
+}

+ 4 - 0
6_ES6/babel/dist/index.js

@@ -0,0 +1,4 @@
+"use strict";
+
+var a = "hello";
+console.log(a);

+ 16 - 0
6_ES6/babel/package.json

@@ -0,0 +1,16 @@
+{
+  "name": "babel",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "devDependencies": {
+    "babel-cli": "^6.26.0",
+    "babel-preset-env": "^1.7.0"
+  }
+}

+ 8 - 0
6_ES6/babel/src/export.js

@@ -0,0 +1,8 @@
+export let a = "hello";
+export function b() {
+    console.log("world");
+}
+
+// export default function () {
+//     console.log("world");
+// }

+ 6 - 0
6_ES6/babel/src/import.js

@@ -0,0 +1,6 @@
+import { a as str,b as foo } from "./export.js"
+console.log(str);
+foo();
+
+// import foo from "./export.js"
+// foo();

+ 2 - 0
6_ES6/babel/src/index.js

@@ -0,0 +1,2 @@
+let a = "hello";
+console.log(a);