Node.js控製台類中的console.log()函數用於在控製台上顯示消息。它使用換行符打印到標準輸出。
用法:
console.log( [data][, ...] )
參數:此函數包含多個要打印的參數。
返回類型:該函數返回傳遞的參數。
下麵的程序演示了console.log()函數的工作:
程序1:
function GFG(name) {
console.log("hello " + name);
}
// when parameters are passed
GFG("Geeksforgeeks");
輸出:
程序2:
function GFG(name) {
console.log("hello " + name);
}
// No parameters are passed
GFG();
輸出:
相關用法
注:本文由純淨天空篩選整理自Twinkl Bajaj大神的英文原創作品 Node.js | console.log() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。