VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-console-debug-method/

⇱ Node.js console.debug() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js console.debug() Method

Last Updated : 5 Apr, 2023

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

Syntax:

console.debug(data, args);

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

  • data: This parameter specifies the data to be printed.
  • args: It is an optional parameter that specifies parameters to be passed as substitution values in messages passed to data. All passed args are sent to util.format().

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

Example 1: The below example illustrates the use of a console.debug() method in Node.js: 

Filename: app.js 

Run the app.js file using the following command:

node app.js

Output:

This is a sample debug message!
Sample debug message with args: 39

Example 2: The below example illustrates the use of a console.debug() method in Node.js:  

Filename: app.js 

Run the app.js file using the following command:

node app.js

Output:

This is a sample debug message!
Sample debug message with args: 34
Debug message: Warning at function ff(): line number 96
Custom debug 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_debug_data_args

Comment

Explore