- 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.info() 方法
Node.js 的 console.info() 方法用於將資訊列印到 stdout(標準輸出流)的新行中。它是 Console.log() 方法的別名。
使用這兩種方法,我們可以將給定的訊息列印到標準輸出流(stdout),即終端或其他日誌記錄機制,例如檔案或網路連線。它接受任意數量的引數,並以空格分隔列印它們,並在末尾新增換行符。
語法
以下是 Node.js console.info() 方法的語法:
console.info(data, …args);
引數
此方法將接受兩個引數。下面描述了它們。
data − 此引數指定要列印到 console 的訊息。
args − 這是一個可選引數,它儲存將傳遞給 data 的替換值。
返回值
此方法不返回任何內容;相反,它將格式化後的資訊列印到 stdout 的新行中,類似於 console.log() 方法。
示例
Node.js 的 console.info() 方法的工作方式類似於 console.log() 方法。此方法接受一個引數(data)。
在此示例中,我們僅使用 data 引數呼叫 console.info() 方法。
console.info("Welcome to tutorialspoint");
console.info("Simply Easy Learning at your fingertips");
輸出
正如我們在輸出中看到的,我們作為 data 引數傳遞的訊息列印到控制檯上的 stdout 的新行中。類似於 Node.js 的 console.log() 方法。
Welcome to tutorialspoint Simply Easy Learning at your fingertips
示例
Node.js 的 console.info() 方法將接受一個可選引數(args)。
在此示例中,我們使用兩個引數 data 和 args 呼叫 console.info() 方法。我們將 string 值作為替換值傳遞。
console.info("Welcome to %s", "tutorialspoint");
console.info("Simply %s Learning at %s fingertips", "Easy", "your" );
輸出
正如我們在輸出中看到的,我們作為 data 引數傳遞的訊息以及 args 引數中的替換值列印到控制檯上的 stdout 的新行中。
Welcome to tutorialspoint Simply Easy Learning at your fingertips
示例
在此示例中,我們使用兩個引數 data 和 args 呼叫 console.info() 方法。我們將 integer 值作為替換值傳遞。
console.info("One - %d Two - %d Three - %d", 1, 2, 3);
console.info("Numbers in above statement %d", 3);
輸出
正如我們在輸出中看到的,我們作為 data 引數傳遞的訊息以及 args 引數中的 integer 替換值列印到控制檯上的 stdout 的新行中。
One - 1 Two - 2 Three - 3 Numbers in above statement 3
