摘要: 编程风格 let取代var 尽量使用const(全局特别如此) 静态字符串不用双引号,使用单引号或者反引号。 使用数组对变量赋值或使用对象或函数返回多个值时,使用解构赋值,如: const arr = [1, 2, 3, 4]; const [first, second] = arr;//first 阅读全文
posted @ 2022-10-24 23:56 梦呓qwq 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 模块 CommonJs(用于服务器),AMD(用于浏览器) // CommonJS模块,生成对象 let { stat, exists, readfile } = require('fs'); // ES6模块 import { stat, exists, readFile } from 'fs'; 阅读全文
posted @ 2022-10-24 23:31 梦呓qwq 阅读(36) 评论(0) 推荐(0) 编辑
摘要: Class的数据类型是函数,类本身就指向构造函数 Class Bar{ } var b=new Bar(); //类的实例的方法与类原型的方法相同: class B{} let b=new B(); b.constructor B.prototype.constructor Class内部的toSt 阅读全文
posted @ 2022-10-24 21:14 梦呓qwq 阅读(133) 评论(0) 推荐(0) 编辑
摘要: async async函数是Generator函数的语法糖.将*换成await,将yield转换为await,不需要co模块那样的执行器来保证自动执行,返回值是Promise(那还用那么麻烦的东西干嘛,cao)。 const asyncReadFile = async function () { c 阅读全文
posted @ 2022-10-24 15:24 梦呓qwq 阅读(75) 评论(0) 推荐(0) 编辑