摘要: 1. 请求的运作过程 2. 前端和后端的定义 前端: font-end is about everything that happens in the web browser. It is about designing and building the final website that's g 阅读全文
posted @ 2022-06-18 03:04 kihyun 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 事件驱动模型,观察者模式 同一个事件,多个监听器 const EventEmitter = require("events"); const myEmitter = new EventEmitter(); // 这里是两个观察者,观察对应的对象,等待对象做出动作 myEmitter.on("newS 阅读全文
posted @ 2022-06-18 03:00 kihyun 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 1. 事件循环的概念: event loop is all the application code that is inside callback functions(non-top-top-level code) 2. 事件循环的步骤 强调的是两个另外的任务队列,他们执行的时机在每个主任务执行完 阅读全文
posted @ 2022-06-18 02:58 kihyun 阅读(105) 评论(0) 推荐(0) 编辑
摘要: stream stream的类型有四种,常见的是前面两种 三段逐渐升级的返回读取文件的代码 fs读取写入 const fs = require("fs"); const server = require("http").createServer(); server.on("request", (re 阅读全文
posted @ 2022-06-18 02:52 kihyun 阅读(24) 评论(0) 推荐(0) 编辑
摘要: Web API 我们要写一个api去读取一个json文件里面的内容 这里是最初的版本 const server = http.createServer((req, res) => { const pathName = req.url; if (pathName "/api") { // __dirn 阅读全文
posted @ 2022-06-18 02:48 kihyun 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 导入http模块 const http = require('http'); 创建server const server = http.createServer((req, res) => { res.end("Hello form the server!"); }); 开启server serve 阅读全文
posted @ 2022-06-18 02:46 kihyun 阅读(49) 评论(0) 推荐(0) 编辑
摘要: fs模块 读取数据 同步读取数据-> readFileSync 参数(path,buffer) const fs = require('fs'); const textIn = fs.readFileSync('./txt/input.txt','utf-8'); console.log(textI 阅读全文
posted @ 2022-06-18 02:45 kihyun 阅读(41) 评论(0) 推荐(0) 编辑
摘要: promise & async/await promise 为什么出现promise? 回调地狱 promise的三个状态 pending fullfilled rejected 真正解决回调地狱 promise里面不嵌套then 每一个都返回一个promise再then const readFil 阅读全文
posted @ 2022-06-18 02:44 kihyun 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 导入模块 导入模块的步骤 导入模块分为五个步骤 解析导入的代码 包装 执行 返回模块 缓存,模块在第一次加载的时候就缓存下来了,第二次请求相同的模块的时候不会重新请求 导入模块的方法 module.exports test-module-1.js两种方式 ①写完类再导出 class Calculat 阅读全文
posted @ 2022-06-18 02:42 kihyun 阅读(62) 评论(0) 推荐(0) 编辑