A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/node-js/node-js-console-info-method/ below:

Node.js console.info() Method - GeeksforGeeks

Node.js console.info() Method

Last Updated : 05 Apr, 2023

The console.info() method is an inbuilt application programming interface of the console module which is used to print messages to stdout in a newline. It is similar to the console.log() method.

Syntax:

console.info(data, args);

Parameters: This method has two parameters as mentioned above and described below:

Return Value: This method doesn't return anything but print the formatted message to stdout in a new line. 

Example 1: The below examples illustrate the use of the console.info() method in Node.js: 

Filename: app.js 

javascript
// Node.js program to demonstrate the
// console.info() method

// Accessing console module
const console = require('console');

// Calling console.info() method
console.info("this is a sample info message!");
console.info("sample info message with args: %d", 39);

Run the app.js file using the following command:

node app.js

Output:

this is a sample info message!
sample info message with args: 39

Example 2: The below examples illustrate the use of the console.info() method in Node.js: 

Filename: app.js 

javascript
// Node.js program to demonstrate the
// console.info() method

// Accessing console module
const console = require('console');

// Calling console.info() method
console.info("this is a %s" +
    " sample info message!");

console.info("sample info message "
    + "with args: %d", 34);
console.info("info message: Warning "
    + "at function %s: line number"
    + " %d ff()", 96)

let isDebugMode = true;
console.custom_info = function (message) {
    if (isDebugMode) {
        console.log(message);
    }
}

console.custom_info("custom info message");

Run the app.js file using the following command:

node app.js

Output:

this is a  sample info message!
sample info message with args: 34
info message: Warning at function ff(): line number 96
custom info message

Note: The above program will compile and run by using the node filename.js command.

Reference: https://nodejs.org/api/console.html#console_console_info_data_args



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4