- Node.js 教程
- Node.js - 首页
- Node.js - 简介
- Node.js - 环境搭建
- Node.js - 第一个应用
- Node.js - REPL 终端
- Node.js - 命令行选项
- Node.js - 包管理器 (NPM)
- Node.js - 回调函数概念
- Node.js - 上传文件
- Node.js - 发送邮件
- Node.js - 事件
- Node.js - 事件循环
- Node.js - 事件发射器
- Node.js - 调试器
- Node.js - 全局对象
- Node.js - 控制台
- Node.js - 进程
- Node.js - 应用扩展
- Node.js - 打包
- Node.js - Express 框架
- Node.js - RESTful API
- Node.js - 缓冲区
- Node.js - 流
- Node.js - 文件系统
- Node.js MySQL
- Node.js - MySQL 入门
- Node.js - MySQL 创建数据库
- Node.js - MySQL 创建表
- Node.js - MySQL 插入数据
- Node.js - MySQL 查询数据
- Node.js - MySQL 条件查询
- Node.js - MySQL 排序
- Node.js - MySQL 删除数据
- Node.js - MySQL 更新数据
- Node.js - MySQL 连接查询
- Node.js MongoDB
- Node.js - MongoDB 入门
- Node.js - MongoDB 创建数据库
- Node.js - MongoDB 创建集合
- Node.js - MongoDB 插入数据
- Node.js - MongoDB 查找数据
- Node.js - MongoDB 查询
- Node.js - MongoDB 排序
- Node.js - MongoDB 删除数据
- Node.js - MongoDB 更新数据
- Node.js - MongoDB 数据限制
- Node.js - MongoDB 连接查询
- Node.js 模块
- Node.js - 模块
- Node.js - 内置模块
- Node.js - 实用工具模块
- Node.js - Web 模块
- Node.js 有用资源
- Node.js - 快速指南
- Node.js - 有用资源
- Node.js - 讨论
NodeJS - console.debug() 方法
Node.js console.debug() 函数用于将信息打印到stdout(标准输出)的新行。它的作用与 Node.js 的console.log() 方法相同。这对于故障排除或理解代码特定部分的工作方式非常有用。现在让我们来看一下console.debug() 方法的语法。
Node.js 的console.debug()是Console类的内置方法。
语法
以下是Node.js console.debug()方法的语法:
console.debug(data, args);
参数
此方法接受两个参数。具体描述如下。
data − 此参数指定要打印到屏幕上的信息。
args − 这是一个可选参数,其中args作为替换值传递到传递给data的信息中。这些args可以通过格式说明符访问。
返回值
此方法不会返回任何值;相反,它会将格式化后的信息打印到stdout的新行,类似于console.log()方法。
示例
Node.js console.debug()方法的工作方式类似于Node.js console.log()方法。此方法接受一个参数 (data)。
在此示例中,我们仅使用data参数调用console.debug()方法。
const console = require('console');
console.debug('Tutorialspoint');
console.debug('Simply Easy Learning at your fingertips...');
输出
正如我们在输出中看到的,我们作为data参数传递的消息被打印到stdout的新行。类似于node.js的console.log()方法。
Tutorialspoint Simply Easy Learning at your fingertips...
示例
node.js的console.debug()方法将接受一个可选参数 (args)。
在此示例中,我们使用两个参数data和args调用console.debug()方法。
const console = require('console');
console.debug('There are %d pancakes in the refrigerator, 4);
console.debug('%s is having a %d pack body', "Nik", 6);
输出
home/cg/root/63a00e1fdca8a/main.js:3
console.debug('There are %d pancakes in the refrigerator, 4);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:238:19)
注意 − 为获得准确的结果,最好在本地执行上述代码。
正如我们在输出中看到的,我们作为data参数传递的消息,以及在args参数中传递的一些替换值,被打印到stdout的新行。
There are 4 pancakes in the refrigerator Nik is having a 6 pack body
nodejs_console_module.htm
广告
