上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 87 下一页
摘要: 1. 创建多进程的模块 1.1 child_process1.2 cluster 2. 创建多进程的方法 2.1 child_process有4种方法: 1. spawn: 创建子进程,执行非node程序,执行结果以流形式返回2. execFile: 创建子进程,执行非node程序,执行结果以回调返 阅读全文
posted @ 2020-04-29 15:58 全玉 阅读(976) 评论(0) 推荐(0) 编辑
摘要: 1. 可选链 可选链,?.操作符,在访问属性或方法时,若存在为空的中间量,则返回undefined,在长链条的属性访问时,可节省代码 const stu = { name: 'xiaoming', school: { name: "xxx" } } const cityName = stu.addr 阅读全文
posted @ 2020-04-29 11:19 全玉 阅读(1820) 评论(0) 推荐(0) 编辑
摘要: function scrollToTop(){ const c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop 阅读全文
posted @ 2020-04-28 17:52 全玉 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 递归写法 function help(root) { return isSymmetric(root, root); } function isSymmetric(node1, node2) { //判断两个节点都是否为空 if (!node1 && !node2) { return true; } 阅读全文
posted @ 2020-04-28 16:44 全玉 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 进程和线程的区别 1. 进程是资源分配的最小单位,线程是程序执行的最小单位,CPU调度的最小单位2. 进程有自己独立的地址空间,线程共享进程的地址空间3. 进程之间的资源是独立的,线程共享本进程的资源 1. 进程间通信 1.1 管道(包括管道和命名管道) 内存中类似于文件的模型,多进程可读写1.2 阅读全文
posted @ 2020-04-28 15:54 全玉 阅读(1371) 评论(0) 推荐(0) 编辑
摘要: thunk版本 function* gen1(){ yield req('1') yield req('2'); yield req('3'); } co(gen1)(); function req(a){ return function(cb){ setTimeout(() => { consol 阅读全文
posted @ 2020-04-27 19:29 全玉 阅读(209) 评论(0) 推荐(0) 编辑
摘要: co的promise版本,就是将函数,generator,generator function,对象,数组等全部转换为promise,在promise的then中,递归的去执行下一个异步流程。其中,object中的promise,通过循环并行执行,array中的异步流程,通过Promise.all来 阅读全文
posted @ 2020-04-27 17:02 全玉 阅读(271) 评论(0) 推荐(0) 编辑
摘要: co的thunk版本,就是将所有 函数,generator,generator function,object,array,promise,都转换为thunk函数,在thunk函数的回调中,切换外部包装的generator的状态,即调用next方法,来依次执行所有的异步任务。其中的,object和a 阅读全文
posted @ 2020-04-27 16:29 全玉 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1. 引用一个目录下的所有js文件 modules下 home.js me.js productList.js user.js 实现 import home from './modules/home' import me from './modules/me' import productList 阅读全文
posted @ 2020-04-27 01:00 全玉 阅读(5158) 评论(0) 推荐(0) 编辑
摘要: 1. nodejs的宏任务回调有6个阶段: timers setTimeout setInterval IO fs.read, fs.write, network idle prepare 准备工作,node内部使用 poll 新加入的IO事件 check setImmediate回调 close 阅读全文
posted @ 2020-04-26 16:44 全玉 阅读(163) 评论(0) 推荐(0) 编辑
上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 87 下一页