- 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
廣告
