当前位置: 首页 > 后端技术 > Node.js

node+node的全局对象简介

时间:2023-04-03 12:49:12 Node.js

为什么使用node的非阻塞IO,适用场景webAPI和网络爬虫主要特点标准类库模块系统npmnode的全局对象1.进程类用于操作系统通信使用进程实现上一行的输入是什么?下一行输出对应的大写字母varprocess=require('process');process.stdin.resume();process.stdin.setEncoding('utf-8');process.stdin.on('data',function(text){process.stdout.write(text.toUpperCase())})使用process获取操作系统的process.stdout.write(process.arch)2.Buffer实例的toString()方法Buffer类的用于将十六进制编码转换为UTF-8字符串。如果要转换成其他格式,可以在toString方法中加上参数('ascii')